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

after exiting i get everything like it suppose to but when i put command 
like this:
command=lambda: onpress(i)
i got only last checkbutton check.

Why i have to pass this default argument?


btw i have python 2.5
thx
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to