multiple check boxes

From: Harish Vaidya (
Date: 11/01/03

Date: Fri, 31 Oct 2003 20:29:27 -0800 (PST)

i am trying to use multiple checkboxes.
what is happening is once select check box its
variable is not getting set. below is the code. what
could be the problem? i am using python 2.0
thanks in advance
from Tkinter import *

def TestCases():

    print 'hi'
    if(name3.var.get() == 1):
        print 'TEST CASE A'

def hostTC():
    if(name1.var.get() == 1):
       print 'TESTSCENARIO A'
       top = Tk()
       y1 = IntVar()
       name3 = Checkbutton(top, text = "TEST CASE A",
      variable = y1, onvalue=1, offvalue=0)
       y2 = IntVar()
       name4 = Checkbutton(top, text="TEST CASE B",
    variable = y2, onvalue=1, offvalue=0)
       name3.var = y1
       name4.var = y2
       b1 = Button(top,

def main():
    global root,name1,name2,name3
    root = Tk()
     x1 = IntVar()
    name1 = Checkbutton(root, text = "Pizza", variable
          = x1, onvalue=1, offvalue=0)
     x2 = IntVar()
    name2 = Checkbutton(root, text="Salad", variable =
    x2, onvalue=1, offvalue=0)
    name1.var = x1
    name2.var = x2
    b = Button(root, text='OK!',command=hostTC())

if __name__ == '__main__':


Do you Yahoo!?
Exclusive Video Premiere - Britney Spears