Look at my short example:
for i in range(10):
myEntry = Entry(root)
myEntry.pack()
myEntry.get()
Is there a way to access .get()
data from the individual Entries? I thought it might be a way to change the objects declaration name inside the for loop.
I'm trying to list user inputs options by pressing a button
CodePudding user response:
You can keep accessing what .get()
returns for each individual Entry
instance by storing the entry in a data structure like a list called my_entries
for example.
You can then access each individual entry directly through the list via indexing or loops, and call .get()
on each entry.
# Create list to store entries
my_entries = []
# Store each individual entry in the list
for _ in range(10):
myEntry = Entry(root)
myEntry.pack()
my_entries.append(myEntry)
# Access each entry individually
for entry in my_entries:
print(entry.get())