My goal is to be able to pass string variables to two different entries for user validation and return the user modified values. The code works fine if it is executed a single time; however, when looped, it only performs correctly during the first iteration of the loop. During subsequent iterations the string variables for the entries are blank.
I have experimented with update_idletasks() and time-sleep without luck. I am running Python 2.4 on Windows XP.
# -*- coding: cp1252 -*-
import Tkinter
def retrieve_text():
app_win.quit()
for item in range(3):
numero_dossier = item+1
version_dossier = item+2
app_win = Tkinter.Tk()
l = Tkinter.Label(app_win, text="Veuillez valider les informations suivantes et les corriger au besoin :")
l.grid(row=0, column=0, columnspan=2)
l.pack()
v1 = Tkinter.StringVar()
v1.set(numero_dossier)
l1 = Tkinter.Label(app_win, text="Numéro de dossier:", anchor='w', justify='left')
e1 = Tkinter.Entry(app_win, textvariable=v1)
l1.pack()
e1.pack()
v2 = Tkinter.StringVar()
v2.set(version_dossier)
l2 = Tkinter.Label(app_win, text="Version du dossier:", anchor='w', justify='left')
e2 = Tkinter.Entry(app_win, textvariable=v2)
l2.pack()
e2.pack()
app_button = Tkinter.Button(app_win,text="OK",command=retrieve_text)
app_button.pack()
app_win.mainloop()
app_win.withdraw()
numero_dossier = e1.get().strip()
version_dossier = e2.get().strip()
print numero_dossier, version_dossier