Tkinter Menus
Tim Daneliuk
tundra at tundraware.com
Sat Dec 14 00:20:08 EST 2002
Justin Shaw wrote:
<SNIP>
>
>
> This version invokes callback when the menu is created:
> m.add_command(label='Call %s' % (label=" ...", callback(i+1))
>
> and so is essentially the same as
> m.add_command(label='Call %s' % (label=" ...", None)
>
> as apposed to the other version which creates a lambda function at menu
> creation time that gets called when the menu is clicked.
Yes, that's what I suspected. But, what I'm trying to understand is
the language semantics here: *why* do the two forms behave the way
they do -i.e., What is it about the lambda form that defers
execution until the time when a menu item is selected?
--
------------------------------------------------------------------------------
Tim Daneliuk
tundra at tundraware.com
More information about the Python-list
mailing list