Re: [Tutor] All Entry Boxes taking the same value
Hi Peter and Alan, Yes, thank you for your suggestions. I really appreciate it. I would look into a proper tutorial and try to follow it up. The suggestion regarding this piece of code worked when I tried StringVar instead of " ". Thank you once again. Yours truly, Pooja On Fri, Mar 31, 2017 at 6:28 AM, Alan Gauld via Tutorwrote: > On 30/03/17 21:35, Pooja Bhalode wrote: > > > *However, when I execute it, and type something in one entrybox, it shows > > in all the entry boxes using multi-cursor option. * > > I'm not sure whats going on and don;t habe tome to experiment but one > thing I noticed: > > > average = [" ", " ", " "] > > lowest = [" ", " ", " "] > > highest = [" ", " ", " "] > ... > > for i in range(len(reactants)): > > *Entry*(root, textvariable =* average[i]*, width = 15, > > state=DISABLED).grid(row = 3+i, column = 1, sticky = W) > > You are setting textvariable to a string but it should be > a StrinVar object. You could probably fix that by changing > your data definitions to StringVars: > > average = [StringVar(), StringVar(), StringVar()] > > I don't know if that will fix the problem but its probably > a good thing to do anyhow... > > > -- > 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 > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] All Entry Boxes taking the same value
On 30/03/17 21:35, Pooja Bhalode wrote: > *However, when I execute it, and type something in one entrybox, it shows > in all the entry boxes using multi-cursor option. * I'm not sure whats going on and don;t habe tome to experiment but one thing I noticed: > average = [" ", " ", " "] > lowest = [" ", " ", " "] > highest = [" ", " ", " "] ... > for i in range(len(reactants)): > *Entry*(root, textvariable =* average[i]*, width = 15, > state=DISABLED).grid(row = 3+i, column = 1, sticky = W) You are setting textvariable to a string but it should be a StrinVar object. You could probably fix that by changing your data definitions to StringVars: average = [StringVar(), StringVar(), StringVar()] I don't know if that will fix the problem but its probably a good thing to do anyhow... -- 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
Re: [Tutor] All Entry Boxes taking the same value
Pooja Bhalode wrote: > average = [" ", " ", " "] > for i in range(len(reactants)): > Entry(root, textvariable = average[i], width = 15, > state=DISABLED).grid(row = 3+i, column = 1, sticky = W) Hint: What is passed as textvariable? What should be? Unfortunately the Entry accepts both StringVar instances and names of StringVar instances which automagically spring into existence -- and " " is a valid name... Pooja, I have been watching your efforts to write one or more python/tkinter scripts mostly via try and error for a while now. It is obvious that it doesn't work as there are so many more ways to go wrong than right. I recommend that you see if you can find a tutorial for both Python and Tkinter, and work through that for a few weeks, say. Once you have a general understanding of programming your progress will be faster, and you won't destroy the result of the previous step with the changes you make in the next. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] All Entry Boxes taking the same value
Hi, I am working on a GUI application where I have a multiple number of entry boxes and I created a loop for the label and entry boxes depending upon the number of times it needs to be shown. However, I tried assigning different values to each label and entry boxes in the for loop using lists, so that I can save different values obtained from the entry boxes in the entry lists and use them later. *However, when I execute it, and type something in one entrybox, it shows in all the entry boxes using multi-cursor option. * Can someone please tell me how I can avoid this error? I am trying to put a for loop since I need to create the gui such that the number of times it needs to be done would be unknown. Hence, the way I went about this was to take an upper limit of 3 and thus, reacoriginal = [" ", " ", " "]. This can be used as an upper limit and the required number can thus fit in as needed. Here, for example, I have taken the required number as two. this would be later modified. Code: from Tkinter import * root = Tk() root.geometry("500x350") # Variables: reacoriginal = [" ", " ", " "] conca = [1,0,0] print conca[0] concunit = [" ", " ", " "] concunit11 = StringVar() concunit21 = StringVar() concunit31 = StringVar() conca1 = IntVar() conca1.set(1) concb1 = IntVar() concc1 = IntVar() average = [" ", " ", " "] lowest = [" ", " ", " "] highest = [" ", " ", " "] averageformulation = [" ", " ", " "] lowestformulation = [" ", " ", " "] highestformulation = [" ", " ", " "] print average reactants = ["A", "B", "C"] for i in range(len(reactants)): Label(root, text = "Experimental Range").grid(row = 0, column = 0, sticky = W) labeldown = Label(root, text = "For Parameter Estimation") labeldown.grid(row = 1, column = 0, sticky = W) labeldown.config(state='disable') Label(root, text = "Average ").grid(row = 2, column = 1, sticky = W) Label(root, text = "Lowest ").grid(row = 2, column = 2, sticky = W) Label(root, text = "Highest").grid(row = 2, column = 3, sticky = W) Label(root, text = "Units").grid(row = 2, column = 4, sticky = W) Checkbutton(root, text = reactants[i], variable = conca[i]).grid(row = 3+i, column = 0, sticky = W) optionlist2 = [u'\u03bcmol/L', 'mmol/L','mol/L'] concunitdrop = OptionMenu(root, concunit[i], *optionlist2) concunitdrop.config(width = 8) concunitdrop.grid(row = 3+i, column = 4, sticky = W) for i in range(len(reactants)): *Entry*(root, textvariable =* average[i]*, width = 15, state=DISABLED).grid(row = 3+i, column = 1, sticky = W) *Entry*(root, textvariable = *lowest[i]*, width = 15).grid(row = 3+i, column = 2, sticky = W) *Entry*(root, textvariable = *highest[i]*, width = 15).grid(row = 3+i, column = 3, sticky = W) root.mainloop() ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor