"Peter Otten" <__pete...@web.de> wrote
I can select/deselect it with the mouse. its just the change to the
variable that is broken.
This was the problem using the Stringvar.
Then var changes OK. Here is my code(from Pythonwin):
def f(): global var; var = 'on' if var == 'off' else 'off';print
var
...
top = Tk()
var = StringVar()
c = Checkbutton(top,text='txt', variable=var, onvalue='on',
offvalue='off', command=f)
c.pack()
top.mainloop()
off
on
I think that is confusing. Tkinter is not supposed to rebind the
global name
'var', it invokes its set() method. Try
Yes, my bad, I should have removed the StringVar assigment it was
just a carryover from the previous attempt. The problem was that
the StringVar was never changing when the control was clicked.
This was my attempt to create a manual solution that avoided the
automated StringVar approach.
def command():
print var.get()
This raises an interesting point though. I was printing var - which
never changed - I forgot about the need to go through a get()
method. Time for another experiment....
Alan G.
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor