[Tkinter-discuss] IntVar() not being attached to Checkbutton

Guilherme Polo ggpolo at gmail.com
Thu Jun 11 02:14:51 CEST 2009


On Wed, Jun 10, 2009 at 7:42 PM, Adam Kadzban<akadzban at iit.edu> wrote:
>
>
> On Wed, Jun 10, 2009 at 5:08 PM, John McMonagle <jmcmonagle at velseis.com.au>
> wrote:
>>
>> Adam Kadzban wrote:
>>
>> > I have the main part of the GUI (which has Checkbuttons that behave
>> > normally), with a menu option to create another window for some
>> > "advanced options".  The code for this window is in its own class, which
>> > takes a list of options as parameters and then has some check boxes and
>> > entry boxes so you can change the option list.  Here's the relevant
>> > code:
>> >
>>
>> It's not all that relevant to me.  Try to reduce your problem to the
>> minimal code which exhibits the indicated behaviour.
>>
>> All I can think of, without seeing your offending code, is maybe the
>> IntVar or the Checkbutton is being garbage collected somehow.
>>
>> Regards,
>>
>> John
>
>
> Stripped down fg.py:  http://pastebin.com/m4c32483e
> Stripped down aow.py:  http://pastebin.com/m4ab77b3d
>
> This still exhibits the behavior for me, is anyone else getting it?

It happens to work for me right now, but what you are doing is just plain wrong.

Inside this fg.py you are instantiating a Tk class, which creates a
Tcl interpreter and loads the tk module (since you didn't tell it to
not load tk). Then when you instantiate this class "window" inside aow
you create another Tcl interpreter by instantiating the Tk class again
(you are not supposed to create multiple Tcl interpreters to show
multiple windows, instead, instantiate Toplevel multiple times). Then
you proceed to create a checkbutton which has this new Tcl interpreter
as the master, but you create the Tcl variable using the previously
created master. So, you are trying to use a variable created in a Tcl
interpreter, with a widget created in a different interpreter and
there is nothing in Tkinter that guarantees you that this will end up
working.

Hope it helps you, and others, to notice how this is not going to work properly.

> Also,
> just realized this laptop is running Ubuntu 8.10, not 9.04, if that makes a
> difference.
>
> -Adam




-- 
-- Guilherme H. Polo Goncalves


More information about the Tkinter-discuss mailing list