On 07/11/15 09:28, Chris Roy-Smith wrote:

B4=Button(main, text='fill text', command=lambda wgt=ofield : genF(wgt))

This certainly wasn't obvious from what I could find on the internet.
Now I see an application for Lambda

I should point out you can use a def if you prefer:

def second():
    main=Toplevel(root)
    ofield=Text(main, height=15, width=15)
    ofield.pack()
    B3=Button(main, text='exit', command=main.destroy)
    B3.pack()
    def genFwrapper(widget = ofield): return genF(widget)
    B4=Button(main, text='fill text', command=genFwrapper)
    B4.pack()


The lambda just saves a line.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to