How to provide context sensative help.

Bernhard Herzog herzog at online.de
Tue Aug 29 13:10:34 EDT 2000


Chuck Meyers <chuck.meyers at lmco.com> writes:

> But str(event.widget) just gives a number.

It returns a string, not a number. If you don't give your widgets your
own names, Tkinter simply uses the decimal representation of the id of
the Python object associated with the Tk-widget:

>>> from Tkinter import *
>>> top = Tk()
>>> f = Frame(top)
>>> f.pack()
>>> str(f)
'.135839768'
>>> label = Label(f, text="Tkinter")
>>> label.pack()
>>> str(label)
'.135839768.135839840'


> For context sensative help you want the python name.

What exactly do you mean by 'python name'?

What you get sith str is the name that is used by tk internally. It's
unique and you should be able to automatically build a dictionary
mapping these names to the help-text or whatever information you need.

-- 
Bernhard Herzog   | Sketch, a drawing program for Unix
herzog at online.de  | http://sketch.sourceforge.net/



More information about the Python-list mailing list