Philippe C. Martin wrote:
menu.add_cascade(label="File", menu=filemenu)
filemenu.add_command(label="New", command=lambda: callback('New'))
filemenu.add_command(label="Open...", command=lambda:
Of course you could do this with named forwarding functions if you
prefer
I'm not sure what 'named forwar
>>l_dec.add_command(label=i, command=lambda x=i: self.__Dec(x))
Woof! I'd better do my homework on lambda !
Thanks,
Philippe
--
***
Philippe C. Martin
SnakeCard LLC
www.snakecard.com
***
--
http://mail.python.org/mailman/listinfo/python-list
"Philippe C. Martin" <[EMAIL PROTECTED]> writes:
> l_dec_list = ['ATR','IN']
>
> for i in l_dec_list:
> l_dec.add_command(label = i, command= lambda: self.__Dec(i))
Give the lambda an argument with a default:
l_dec.add_command(label=i, command=lambda x=i: self.__Dec(x))
--
Michael Fuhr
http:
I face a strange behavior when adding menu labels / command parameters
from a list:
***
This is the code that works but I wish to avoid - ATR and IN appear in
the menu, and __Dec is called with ATR or IN depending on the choice
***
l_dec.add_command(label = 'ATR', command= lambda: self.__Dec('ATR
>>menu.add_cascade(label="File", menu=filemenu)
>>filemenu.add_command(label="New", command=lambda: callback('New'))
>>filemenu.add_command(label="Open...", command=lambda:
callback('Open'))
>>filemenu.add_separator()
>>filemenu.add_command(label="Exit", command=lambda: callback('Exit'))
mainloop()
Philippe C. Martin wrote:
I have many menu items and would like them all to call the same method
-However, I need the method called to react differently depending on the
menu item selected. Since the menu command functions do not seem to
receive any type of event style object, is there some type of
Hi,
I have he following need and do not find an easy way out:
I have many menu items and would like them all to call the same method
-However, I need the method called to react differently depending on the
menu item selected. Since the menu command functions do not seem to
receive any type of eve