I am a new Python user. I try to make a serie of entries identified by labels and gets the values inserted. The callback functions seem well done but it's allways the third entry's value which I reach. I am Python/Linux user, version 2.7.6 It seem to be lambda's declaration issue, can you help me ?
import Tkinter as tk
class c1(tk.Frame):
def __init__(self, master=None):
r = 0
tk.Frame.__init__(self, master)
self.grid()
self.master.title('Test three binds')
self.master.geometry('300x200+400+400')
self.ents = {}
for i in ['aaa', 'bbb', 'ccc'] :
r += 1
self.ents[i] = c2()
self.ents[i].label = tk.Label(text = i)
self.ents[i].label.grid (row = r, column = 0)
self.ents[i].entry = tk.Entry()
self.ents[i].entry.grid (row = r, column = 1)
self.ents[i].val = tk.StringVar()
self.ents[i].val.set(i)
self.ents[i].entry["textvariable"] = self.ents[i].val
self.ents[i].entry.bind('<Key-Return>', lambda X : self.verif(self.ents[i]))
def verif(self, event) :
print event.val.get()
class c2 :
pass
mm = c1()
for ii in mm.ents :
print mm.ents[ii].val.get()
mm.mainloop()