revise :command=lambda

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

revise :command=lambda

from Tkinter import *
fields = 'Name', 'Job', 'Pay'

def fetch(event,entries):
   for entry in entries:
       print 'Input => "%s"' % entry.get()       # get text
       print  event.widget 
def makeform(root, fields):
   entries = []
   for field in fields:
       row = Frame(root)                           # make a new row
       lab = Label(row, width=5, text=field)       # add label, entry
       ent = Entry(row)
       row.pack(side=TOP, fill=X)                  # pack row on top
       ent.pack(side=RIGHT, expand=YES, fill=X)    # grow horizontal
   return entries

if __name__ == '__main__':
   root = Tk()
   ents = makeform(root, fields)
   root.bind('<Return>', lambda event,entries=ents: fetch(event,entries))       
   Button(root, text='Fetch', command= lambda event:fetch(event,entries)).pack(side=LEFT)  # #how to revise it?

in the code ,the bind method is ok, how to revise "command=lambda event:fetch(event,entries)",to make it work too??

Tkinter-discuss mailing list
[hidden email]