Tkinter widgets: Write options *and* option tags dynamically from dictionary?

Eric Brunel eric.brunel at pragmadev.com
Wed Feb 6 06:18:18 EST 2002


<posted & mailed>

Hi Johannes,

> def __init__(self, master=None, **kw):
>       Frame.__init__(self, master)
>      ...
>       self.label = Label(self, text=kw['labelText'])
> ...
> 
> But then, how do I handle default values, and how do I ensure that the
> objects are created with the right parameters?

Do not use kw['labelText'], but kw.get('labelText', ''). The get method on 
a dictionary does just what you want. Please refer to:
http://www.python.org/doc/current/lib/typesmapping.html

HTH
 - eric -



More information about the Python-list mailing list