Tkinter- checkbutton

Jim Segrave jes at
Fri Nov 4 18:50:08 CET 2005

In article <1131124290.860885.105430 at>,
Tuvas <tuvas21 at> wrote:
>Ere, ignore the mis-capped Checkbutton and the missed master call in

You need to use a Tkinter variable (IntVar, StringVar or whatever),
associate it with the Checkbutton, and access it with the get() and
set() methods:

from Tkinter import *

root = Tk()

v = IntVar()

def do_stuff_here():
    print "Value is zero"

def do_other_stuff_here():
    print "Value is not zero"

def check():
    if v.get() == 0:
    elif v.get() == 1:
        print "This is impossible, but it happened"

b = Checkbutton(root, text = 'Press Me', command = check, variable = v)
b.grid(row = 0, column = 0)

Jim Segrave           (jes at

More information about the Python-list mailing list