Re: Programmatic links in a TKinter TextBox
- From: "Grooooops" <JOHNWUN@xxxxxxx>
- Date: 15 Jun 2005 10:28:17 -0700
Many thanks Jeff!!!
This is what should be in the TK docs. Your example was very clear.
And now I've learned some new stuff... :)
For my project, I needed to add three pieces of data per link like
this:
text.insert(Tkinter.END, "link", ("a", "href:"+href,"another:This Is
More Data", "last:and one more bit for fun"))
I tweaked the above example here to catch multiple bits by adding a
couple elif statements to the for loop, and removing the break lines.
def click(event):
w = event.widget
x, y = event.x, event.y
tags = w.tag_names("@%d,%d" % (x, y))
for t in tags:
if t.startswith("href:"):
print "clicked href %s" % t[5:]
#commented out the break
elif t.startswith("another:"):
print "clicked href %s" % t[8:]
# commented out the break
elif t.startswith("last:"):
print "clicked href %s" % t[5:]
else:
print "clicked without href"
return "break"
Thanks again, I hope others will find this as useful as I did..
.
- References:
- Programmatic links in a TKinter TextBox
- From: Grooooops
- Re: Programmatic links in a TKinter TextBox
- From: Jeff Epler
- Programmatic links in a TKinter TextBox
- Prev by Date: Re: What is different with Python ?
- Next by Date: Re: What is different with Python ? (OT I guess)
- Previous by thread: Re: Programmatic links in a TKinter TextBox
- Next by thread: PIGIP (Python Interest Group In Princeton) Meeting Tonight
- Index(es):
Relevant Pages
|