469,336 Members | 5,173 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,336 developers. It's quick & easy.

Tkinter CheckButton variables

My CheckButton variables seem always to be true, whether the box is checked or
not, which makes them considerably less useful. Following is a little script
that illustrates the difficulty. Any help will be greatly appreciated. Thank
you.

###########################################

from Tkinter import *

def bCommand():
if c['variable']: ## ALSO TRIED: if cVbl
print 'bool(cVbl)==True'
else:
print 'bool(cVbl)==False'

root = Tk()
cVbl = IntVar()
c = Checkbutton(root,variable=cVbl)
c.pack(side=LEFT)
b = Button(root,height=1,width=10,command=bCommand)
b.pack(side=LEFT)
root.mainloop()
Jul 18 '05 #1
1 3118
"Elaine Jackson" <el***************@home.com> wrote in message news:<OSMEc.954254$oR5.38158@pd7tw3no>...
My CheckButton variables seem always to be true, whether the box is checked or
not, which makes them considerably less useful. Following is a little script
that illustrates the difficulty. Any help will be greatly appreciated. Thank
you.

###########################################

from Tkinter import *

def bCommand():
if c['variable']: ## ALSO TRIED: if cVbl
print 'bool(cVbl)==True'
else:
print 'bool(cVbl)==False'

root = Tk()
cVbl = IntVar()
c = Checkbutton(root,variable=cVbl)
c.pack(side=LEFT)
b = Button(root,height=1,width=10,command=bCommand)
b.pack(side=LEFT)
root.mainloop()


c[variable'] returns (of course) cVb1 and therefore will always be true.
You should use

if cVb1.get():
(etc.)

Michael
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by max(01)* | last post: by
6 posts views Thread by max(01)* | last post: by
5 posts views Thread by max(01)* | last post: by
3 posts views Thread by Tuvas | last post: by
1 post views Thread by Michael Yanowitz | last post: by
6 posts views Thread by JyotiC | last post: by
2 posts views Thread by Gigs_ | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by haryvincent176 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.