I was working on a tkinter page that created a variable amount of Entry widgets as it was in a for loop. The code is as follows:
EntryList = ["Enter value 1", "Enter value 2", "Enter value 3", "Enter value 4"]
Now I plan on letting the user add how many entries they want. So the size of the EntryList
would change based on that.
for i in EntryList:
count = EntryList.index(i)
Heading = Label(root, text=i)
Heading.grid(row=count, column=0)
myinput = Entry(root)
myinput.grid(row=count, column=1)
This produces the UI that I desire, where there is a Text box asking what value to enter and an Entry box next to it. This is repeated x number of times specified by the user.
The user will be able to enter the values corresponding to the heading.
But I was not able to find a way to myinput.get()
the values in all of the 'x' number of Entry Widgets as all of them have the same variable name due to the for
loop. The best I could do was get the value of the last Entry Widget.
Is there any work around to this?
Edit: I need this in a frame and has to happen multiple times as many buttons will have similar variations of this code as their command.
I found a solution to it in stackoverflow but the program uses an app and does not get me the desired results as I do not know how I can get it to work in a frame.
Perhaps the next set of Text box and Entry Box would load after the user presses Enter? And that way I can save the value of myinput.get()
into a list before the for
loop continues?
Edit: Got the solution in a new post where I expressed my problem better. Sorry but I am new to a lot of stuff around here.