Marking hyperlinks in a Text widget
Cliff Crawford
cjc26 at nospam.cornell.edu
Sat Jun 3 10:59:31 EDT 2000
* André Dahlqvist <andre at beta.telenordia.se> menulis:
| > That's actually a command-line argument of Unix versions of Netscape. I
| > don't know if it would work on Windows. If you're using Unix, try
| > typing the following at a shell prompt (with Netscape already running):
| >
| > % netscape -remote 'openURL(www.python.org)'
|
| Yeah, I'm on UNIX. I haven't really messed that much with the URL
| opening yet, but this is how I have thought it should work:
|
| common_browsers = ['mozilla', 'netscape', 'lynx', 'w3m']
|
| for browser in common_browsers:
| if not os.system(browser + URL)
| # found browser
| break
Running netscape this way will fail if the user is already running it;
to get around this you can check if it is running (using the output of
os.popen("ps ax")) and use the openURL command if it is.
| But the thing is that I haven't used your URL inserting, because
| it won't work in my application. I did however use the same code for
| tagging the URLs.
|
| So for me doing this will only return the name of the tag for me:
|
| URL = textwidget.tag_names("@%d, %d" % (event.x, event.y)
|
| URL will be 'url' after this call. The last braces [1] that you use doesn't
| apply to my code since I haven't used that insert code you did, right?
Right, you'll have to read the text directly from the widget itself.
You won't even need to use tag_names in this case.
| Now this is what is driving me nuts, it should be so simple but I just
| can't get it to work! If you want I can send you my code so you can
| look at it.
You could even post it so that everyone could look at it :)
| > The callback function takes an argument (event), and you can get
| > the x and y positions where the mouse was clicked using event.x and
| > event.y. So if you want to use tag_ranges, you could just look for the
| > range which contains (event.x, event.y).
|
| Aha, that I can do.
--
cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/
Synaesthesia now! icq 68165166
More information about the Python-list
mailing list