HTML links in a GUI tkinter

Andres Rosado arosado at
Tue Jun 4 19:59:57 EDT 2002

At 03:21 PM 6/3/2002 +0000, you wrote:
>Message: 10
>    Date: Mon, 3 Jun 2002 15:23:47 +0000
>    From: Eric Brunel <eric.brunel at>
>Subject: Re: HTML links in a GUI tkinter
>Steve Holden wrote:
> > So, all Aurel needs to know now is how to run wxPython widgets inside
> > tkinter programs...
>Why? Tkinter has everything to do it:
>from Tkinter import *
>root = Tk()
>t = Text(root)
>def openHLink(event):
>   start, end = t.tag_prevrange("hlink",
>                                t.index("@%s,%s" % (event.x, event.y)))
>   print "Going to %s..." % t.get(start, end)
>t.tag_configure("hlink", foreground='blue', underline=1)
>t.tag_bind("hlink", "<Control-Button-1>", openHLink)
>t.insert(END, "This is a link\n")
>t.insert(END, "", "hlink")
>t.insert(END, "\nAnd text goes on...\n")
>Control-click on the link and you should see the message "Going to <link
>text>", which may be replaced by a to actually open the
>URL. To insert a new link, just do:
>t.insert(<pos>, <url>, "hlink")

By far a more simpler solution. Thanks!


Andres Rosado
Email: andresr at
ICQ: 66750646

You should emulate your heros, but don't carry it too far.
Especially if they are dead.

More information about the Python-list mailing list