help: menu item callback in TK
Steve Holden
sholden at bellatlantic.net
Wed Feb 23 00:02:33 EST 2000
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"
More information about the Python-list
mailing list