Hi, Thus spoketh pyt...@bdurham.com unto us on Fri, 19 Nov 2010 17:25:38 -0500:
> I'm looking for an example of how to use <<MenuSelect>> to > determine currently selected menu item. > > Use case: Display a context sensitive help message in an > application's statusbar as a user navigates through various menu > items. > Maybe you are better off with a simple Motion event, you can access the menu item under the mouse pointer through the menu's index() method (from the menu manpage: Many of the widget commands for a menu take as one argument an indicator of which entry of the menu to operate on. These indicators are called indexes and may be specified in any of the following forms: (...) @number In this form, number is treated as a y-coordinate in the menu's window; the entry closest to that y-coordinate is used. For example, `...@0'' indicates the top-most entry in the window. ) So, in this simple example, you will surely see the point: ################################ from Tkinter import * root = Tk() m = Menu(root) m.add_command(label='foo') m.add_command(label='bar') m.add_command(label='blah') root.bind('<3>', lambda event: m.tk_popup(event.x_root, event.y_root)) def callback(event): try: print m.entrycget(m.index('@%d' % event.y), 'label') except TclError: print 'this must have been the tearoff or something' m.bind('<Motion>', callback) root.mainloop() ################################ I hope this helps Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Extreme feminine beauty is always disturbing. -- Spock, "The Cloud Minders", stardate 5818.4 _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org http://mail.python.org/mailman/listinfo/tkinter-discuss