help: menu item callback in TK
Lin Li
linli at computer.org
Wed Feb 23 08:30:11 EST 2000
Steve Holden wrote:
> lin li wrote:
> >
> > Hi,
> >
> > I have the following problem and any help is greatly appreciated.
> > I generated a menu using the data in a dynamically composed list.
> > Since I do not know what will be in the list, I can only have all the
> > command items in the menu to point to the same callback. Now
> > from inside the callback, how can I find out which menu item is
> > selected? To make it more interesting, the menu can have two or
> > three levels of cascades.
> >
> > I am running Python 1.5.2 with Tkinter on NT.
> >
> > Thank you very much.
> >
> > Lin
>
> Since you clearly must have the menu string available when you construct
> the menu, can't you use the menu string in building a lambda which you
> can use as your callback function? The lambda could call a function
> common to all menu items, and inside that function you would be able to
> access the string the user had selected.
>
> regards
> Steve
> --
> "If computing ever stops being fun, I'll stop doing it"
Provided, of course, that I know how to use lambda. I decided to call this
an incentive and start learning.
Thanks a lot.
Lin
More information about the Python-list
mailing list