Help With Tkinter.Checkbutton Widget

Abhijeet Mahagaonkar abhijeet.manohar at gmail.com
Fri Feb 18 08:42:00 CET 2011


Dear Pythoners,

I have a list of dictionaries. Here i have a variable which should gather
input from  Checkbutton widget in Tkinter. The Problem that I'm facing is
that I'm unable to set or reset the key in every dictionary using the
checkbutton widget.

Here is what i have been doing.

list_of_dict=[{'Flag':0},{'Flag':0}, {'Flag':0}]
root=Tkinter.Tk()

while i<3:
    q=Tkinter.IntVar()
    w=Tkinter.Checkbutton(root, text='Need to include this value?',
onvalue=1, offvalue=0, variable=q)
    w.grid(row=i)
    list_of_dict[i]['Flag']=q.get()
root.mainloop()

Could you please let me know what I'm doing wrong?
I have tried multiple ways of accomplishing this for eg. by having a command
option which will just toggle the
list_of_dict[i]['Flag']=not(list[i]['Flag'])

Please let me know the best way of doing this.
Thanks in advance :)

Warm Regards,
Abhijeet.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110218/05a86567/attachment.html>


More information about the Python-list mailing list