Tkinter: passing parameters to menu commands (looping througha list)

Michael Fuhr mfuhr at fuhr.org
Fri Jan 7 16:56:54 EST 2005


"Philippe C. Martin" <philippecmartin at sbcglobal.net> 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://www.fuhr.org/~mfuhr/



More information about the Python-list mailing list