Check buttons, the hard way (without variables) : Checkbutton « Tkinker « Python Tutorial






Check buttons, the hard way (without variables)
from Tkinter import *      
states = []
def onPress(i):                        
    states[i] = not states[i]          
     
root = Tk()
for i in range(10):
    chk = Checkbutton(root, text=str(i), command=(lambda i=i: onPress(i)) )
    chk.pack(side=LEFT)
    states.append(0)
root.mainloop()
print states








18.6.Checkbutton
18.6.1.Check buttons, the easy wayCheck buttons, the easy way
18.6.2.Check buttons, the hard way (without variables)Check buttons, the hard way (without variables)
18.6.3.Checkbox button barCheckbox button bar
18.6.4.Use Check buttons to change the fontUse Check buttons to change the font
18.6.5.React to the check state of a check boxReact to the check state of a check box
18.6.6.RadioButtons and CheckButtonRadioButtons and CheckButton