Reputation: 18239
I'd like to create a function (I called it super_function
below) that closes the window, records all the information written in the different Entry
and store it in a list.
Here is my current code:
from Tkinter import *
def super_function():
# super_function that should store Entry info
# in a list and close the window
fen1 = Tk()
entr = []
for i in range(10):
entr.append(Entry(fen1))
entr[i].grid(row=i+1)
Button(fen1, text = 'store everything in a list', command = fen1.quit).grid()
fen1.mainloop()
Thank you!
Upvotes: 1
Views: 871
Reputation:
This should do it:
from Tkinter import *
def super_function():
out = map(Entry.get, entr)
fen1.destroy()
print out
fen1 = Tk()
entr = []
for i in xrange(10):
entr.append(Entry(fen1))
entr[i].grid(row=i+1)
Button(fen1, text = 'store everything in a list', command = super_function).grid()
fen1.mainloop()
When you press the button, everything that is in the Entries is gathered into a list which is then printed in the terminal. Then the window closes.
Upvotes: 1