On 27/02/17 03:06, Pooja Bhalode wrote: > The following code creates a list of checkboxes
It would really help uif you posted in plain text. The HTML/RTF is getting very hard to read with no indentation. > ones that user wants, I am trying to add the selected variables to another > list so that the selected variables can be accessed later in the code. > However, when I try appending to the new list, it gets appended as PY_VAR > instead of the variable name associated. > keqparam = IntVar() > delHrxnparam = IntVar() > kfparam = IntVar() > Afparam = IntVar() > ksimparam = IntVar() > Aparam = IntVar() > RAparam = IntVar() > RCparam = IntVar() > > total_number_parameters = IntVar() > selectedparam = [] > checkboxVars = [keqparam, delHrxnparam, kfparam, Afparam, ksimparam, > Aparam, RAparam, RCparam] ... > def SubmitParam(): > global total_number_parameters > total_number_parameters = RCparam.get() + RAparam.get() + Aparam.get() + > ksimparam.get() + Afparam.get() + kfparam.get() + delHrxnparam.get() + > keqparam.get() > print total_number_parameters I assume this works OK and you see the correct value printed? > for i in range(len(checkboxVars)): > if checkboxVars[i].get() == 1: > print checkboxVars[i] > selectedparam.append(checkboxVars[i]) So here you append an IntVar object. How does an IntVar show up in a ptrint? >>> from Tkinter import * >>> top = Tk() >>> v = IntVar() >>> print(v) PY_VAR0 Which is what you see. You need to use get() to get the value: >>> print v.get() 0 >>> > however, when I try to print selectedparam, I get the following output: > [<Tkinter.IntVar instance at 0x104829098>, <Tkinter.IntVar instance at > 0x104829128>] > And when I try to print out checkboxVar[i] which is just above the previous > line, I get PY_VAR2 > PY_VAR3 Hopefully the reasons are now clear? You are seeing Python's descriptions of the objects. To see the values you need to use the get() method. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor