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

Johannes Eble skywalkerpackage at
Wed Feb 6 07:25:33 EST 2002

Hello Eric,

thanks very much for your quick response. Now I have get the error

Traceback (most recent call last):
line 301, in RunScript
    exec codeObject in __main__.__dict__
  File "D:\python\activestate\python21\myscripts\",
line 9, in ?
    apply(bt.config, (), optionDict)
  File "D:\PYTHON\ACTIVESTATE\PYTHON21\lib\lib-tk\", line
1085, in configure, 'configure')
TclError: unknown option "-labelText"

although bt is an intstance of LabelEntry and it has the labelText

I think the problem is that I haven't defined a config method in my
Class LabelEntry. It thought that this is not necessary.

When I define a config method, I have the problem that some of the
LabelEntry options (padx and pady) are options for the packer of the
widgets inside (that is, Label and Entry). So, I can't just write
something like

    def config(self, kw):

Puh, wired problem for me :<

I think I won't use apply, but use the call by dictionary option


On Wed, 6 Feb 2002 11:18:18 +0000, Eric Brunel
<eric.brunel at> wrote:

><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:
> - eric -

More information about the Python-list mailing list