multiple check boxes

Harish Vaidya hrmrv at yahoo.com
Fri Oct 31 23:29:27 EST 2003


hi,
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)
       name3.grid()
       y2 = IntVar()
       name4 = Checkbutton(top, text="TEST CASE B",   
    variable = y2, onvalue=1, offvalue=0)
       name4.grid()
       name3.var = y1
       name4.var = y2
       b1 = Button(top,
text='OK!',command=TestCases())
       name3.pack()
       name4.pack()
       b1.pack()
       Tkinter.mainloop()
    
           

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

    
if __name__ == '__main__':

    main()
   


__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/





More information about the Python-list mailing list