Programmatic links in a TKinter TextBox

Grooooops JOHNWUN at aol.com
Wed Jun 15 12:12:15 EDT 2005


I've been hacking around this for a few days and have gotten close to
what I want... but not quite...

The TKinter Docs provide this example:
    # configure text tag
    text.tag_config("a", foreground="blue", underline=1)
    text.tag_bind("a", "<Enter>", show_hand_cursor)
    text.tag_bind("a", "<Leave>", show_arrow_cursor)
    text.tag_bind("a", "<Button-1>", click)
    text.config(cursor="arrow")

    #add text
    text.insert(INSERT, "click here!", "a")

    #add a link with data
    text.insert(END, "this is a ")
    text.insert(END, "link", ("a", "href"+href))

What I don't understand is how the function "click" sees the "href"
text.

def click(self, data):
    #this doesn't work
    print data

The print statement inside function "click" displays:
<Tkinter.Event instance at 0x01A1FFA8>

If I try to access the link data like this "data[0]" I get an error.

I'm not planning to use web links, I just need each link to send unique
data to the "click" function.
How can I retrieve the custom link data from within my function???




More information about the Python-list mailing list