[Tkinter-discuss] Looking for example of how to use <<MenuSelect>> to determine currently selected menu item

Michael Lange klappnase at web.de
Sun Nov 21 13:13:57 CET 2010


Hi Mick,

Thus spoketh "Michael O'Donnell" <michael.odonnell at uam.es> 
unto us on Sun, 21 Nov 2010 13:05:49 +0100:

> Hi Michael,
> 
> At least in Python 2.5.4 linked to Tk 8.4 (Windows version),
> the following fails  because event.widget holds a string (the tcl/tk
> widget name), not a Tkinter class.
> 
> > def callback(event):
> >    print event.widget.index('active')
> 
> Maybe fixed in later editions, but if one wants a solution that will
> work on older versions...

I see, this happens only with cascade menus, in my example I only had a
popup menu, for which it worked as expected. Right now I am trying to
figure out what's wrong with Tkinter (it's definitely a bug within
Tkinter.py, and I doubt that it has been fixed since 2.6.5), I'll send
another post when I know more. Of course for now you are right, your code
"just works" :)

Regards

Michael


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

Uncontrolled power will turn even saints into savages.  And we can all
be counted on to live down to our lowest impulses.
		-- Parmen, "Plato's Stepchildren", stardate 5784.3


More information about the Tkinter-discuss mailing list