[Tkinter-discuss] revise :command=lambda

守株待兔 1248283536 at qq.com
Tue Aug 23 04:19:26 CEST 2011

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??
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20110823/2d78426f/attachment-0001.html>

More information about the Tkinter-discuss mailing list