Woody
Woody

Reputation: 3

How do I pull entered values from entry box made through a range

I have to make 10 entry boxes and rather than do each one individually, I've done them like this:

for i in range(0,10):
    widthEntry = Entry(root, width=int(9.5), relief='solid')
    widthEntry.grid(row=i+7, column=2, ipady=2)

so how do I pull the value entered into, for example, entry box 7 so that I can use that value in calculations? I'm using Python and Tkinter

Upvotes: 0

Views: 68

Answers (1)

Shuang Wu
Shuang Wu

Reputation: 130

Use a list to contain the Entry instances.

entries = []
for i in range(0,10):
    widthEntry = Entry(root, width=int(9.5), relief='solid')
    widthEntry.grid(row=i+7, column=2, ipady=2)
    entries.append(widthEntry)

Get the 7th entry box:

entries[6].get()

Upvotes: 1

Related Questions