By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,373 Members | 1,763 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,373 IT Pros & Developers. It's quick & easy.

How to generate dictionary from selected checkbutton text as key and status as value

P: 5
I have generated checkbutton from inputstatus dictionary to set as default values.After tht once it get display on GUI when i select it respected text and status will be added to new dictionary

Expand|Select|Wrap|Line Numbers
  1.  
  2.     '''inputstatus = {
  3.             'maggi': 1, \
  4.             'pizza': 1, \
  5.             'cold drinks': 1, \
  6.             'fries': 1, \
  7.             'chapati': 0, \
  8.             'dip': 0
  9.             }'''
  10.         r=3
  11.         cardtype = list(inputstatus)
  12.         for ins in cardtype[:5]:
  13.             print inputstatus[ins]
  14.             if inputstatus[ins]== 1:
  15.                 chk_card = Checkbutton(self.frm1, text= ins, variable= inputstatus[ins])
  16.                 chk_card.select()
  17.             else:
  18.                 chk_card = Checkbutton(self.frm1, text= ins, variable= inputstatus[ins])
  19.                 chk_card.deselect() 
  20.             chk_card.grid(row=r,column=1)
  21.             r=r+1
  22.  
  23.  
this code only displays checkbutton based on default status after selection of checkbutton i need new dictionary which have
current status of menu like {'pizza':0,'chapati':1,....}
Oct 14 '16 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 618
The GUI has nothing to do with updating the dictionary other than using the checkbutton to call a function that updates the dictionary/ Since we do not know how you get the data used to update the dictionary there is little more help that can be given.
Oct 14 '16 #2

Post your reply

Sign in to post your reply or Sign up for a free account.