[Tutor] Checkbox problem in Tkinter
Peter Otten
__peter__ at web.de
Mon Jan 10 12:38:25 CET 2011
ANKUR AGGARWAL wrote:
> Hey I write this code up
>
> from Tkinter import *
> root=Tk()
> var=StringVar()
>
c=Checkbutton(root,text="hello",variable=var,onvalue="hhhh",offvalue="gggg")
> c.pack()
> root.mainloop()
>
> and i got the output as -
> [image: Screenshot.png]
>
> When i take the var as of string variable type i am unable to edit the
> checkbox. It comes slected predefined and the widget in kindof Invisible
> and
> u can say uneditable. Can anybody tell me whats i am doing wrong in
> this??? Its works fine if i take the var variable as the integer variable.
> I can deselect and select in that case and it gives me the desired result
> but in string case i am unable to do so as checkbox is invisible type.
> I am using Python 2.6
> Thanks In Advance
> Ankur Aggarwal
The variable appears greyed out because initially var.get() == "", see
http://www.tcl.tk/man/tcl8.5/TkCmd/checkbutton.htm#M-tristatevalue
More information about the Tutor
mailing list