Marking hyperlinks in a Text widget
André Dahlqvist
andre at beta.telenordia.se
Thu Jun 1 08:38:15 EDT 2000
> 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
> It actually returns the entire tuple we stored as its tag, not just the
> first tag name. Since the url was already entered as the second element
> of this tuple, we just do
>
> textw.tag_names(...)[1]
>
> to retrieve it.
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?
Even if I try [0] it doesn't work.
> Nope; you just need to know the coordinate of one of the characters
> within the url. The character closest to where the mouse was clicked is
> the most convenient one to use :)
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.
> 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.
// André
More information about the Python-list
mailing list