Tkinter Puzzler
Tim Daneliuk
tundra at tundraware.com
Fri Jan 7 06:28:31 EST 2005
Tim Daneliuk wrote:
> I am trying to initialize a menu in the following manner:
>
> for entry in [("Up", KeyUpDir), ("Back", KeyBackDir), ("Home",
> KeyHomeDir), ("Startdir", KeyStartDir), ("Root", KeyRootDir)]:
>
> func = entry[1]
> UI.ShortBtn.menu.add_command(label=entry[0], command=lambda:
> func(None))
>
> However, at runtime, each of the menu options binds to the *last* function
> named in the list (KeyStartDir).
>
> Explicitly loading each entry on its own line works fine:
>
> UI........command=lambda:KeyWHATEVERDir(None)
>
> Any ideas why the first form does not fly?
>
>
> TIA,
> ----------------------------------------------------------------------------
>
> Tim Daneliuk tundra at tundraware.com
> PGP Key: http://www.tundraware.com/PGP/
Thanks All - great responses!
--
----------------------------------------------------------------------------
Tim Daneliuk tundra at tundraware.com
PGP Key: http://www.tundraware.com/PGP/
More information about the Python-list
mailing list