"ANKUR AGGARWAL" <coolankur2...@gmail.com> wrote
from Tkinter import *
root=Tk()
var=StringVar()
c=Checkbutton(root,text="hello",variable=var,onvalue="hhhh",offvalue="gggg")
c.pack()
root.mainloop()
FWIW I get a different problem, namely that the var does not seem
to get updated nor does changling the var seem to alter the buuttons
state. But at least the button displays OK with 'hello' in the label
and
I can select/deselect it with the mouse. its just the change to the
variable that is broken.
If I write an explicit event handler:
def f():
var = 'hhhh' if var == 'gggg' else 'gggg'
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
off
on
off
on
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor