Dynamic command on Menu items?

Joe S joeschey at earthlink.net
Wed Aug 25 15:54:30 EDT 2004


(Python newbie alert..only 1 week's experience)

I want to create several menu items based upon a config file. In this
config file are label, function and a parameter. I want to show label
in the menu, then when it's chosen, call function with the given
parameter.

How can I do the correct equivalent of the following (which definitely
doesn't work)?

l='Zooks'
f='func'
p='Got Zooks'
M.menu.add_command(label=l, command=lambda: f(p))

so that when I pick 'Zooks' from the menu, func gets called with 'Got
Zooks'.


Joe



More information about the Python-list mailing list