Oooh I see! I knew it was a small thing I was overlooking. I read in the reference "Tkinter variable", but I never gave it the meaning it really had. Thanks everyone!
Gerardo On Wed, 29 Nov 2006, Fredrik Lundh wrote: > Gerardo Juarez wrote: > > > > I'm having problems with a widget, which I've been able to isolate to the > > following example: > > > > from Tkinter import * > > > > def display(): > > global x > > print x > > > > root = Tk() > > x = 0 > > check = Checkbutton(root, variable=x) > > check.pack() > > button = Button(text='Display variable', command=display) > > button.pack() > > root.mainloop() > > > > As far as I understand the reference, when I click the button, the > > variable 'x' should reflect the state of the check button > > you must use a Tkinter variable object, not an arbitrary Python variable: > > http://effbot.org/tkinterbook/checkbutton.htm#patterns > > (note that in Python, the parameter expressions are *always* evaluated > before the function is actually called, so "variable=x" will pass a zero > to the checkbutton. you cannot pass references to variable names in > Python, only references to objects). > > </F> > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss@python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org http://mail.python.org/mailman/listinfo/tkinter-discuss