0

Wondering if there's a menu event I can bind to that's related to the currently selected menu item? By menu item I mean the items that show up in a popup menu like New, Open, Save, etc.

Use case: I would like to update a statusbar area of our application with a description of the currently selected menu item.

Any ideas appreciated.

Thank you, Malcolm

Malcolm
  • 5,125
  • 10
  • 52
  • 75
  • Relevant solution: [add-a-tooltip-to-menu-item](https://stackoverflow.com/questions/55316791/how-can-i-add-a-tooltip-to-menu-item-in-tkinter-python-2-7/55343447#55343447) – stovfl Mar 26 '19 at 11:05

2 Answers2

2

You need to bind to the <<MenuSelect>> event.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
  • Thank you. The <> event is exactly what I'm looking for. Unfortunately, I'm having a challenge trying to manage this event once I've captured it. Specifically, I bind to a function defined as update_statusbar( event=None ). A simple print statement within this function confirms that my event binding is correct. However, event.widget returns a string vs. a widget reference. It looks like I'm not getting a normal event object. Does this sound right? Any suggestions on how I can determine the currently selected menu item via the event object I receive? – Malcolm Nov 19 '10 at 22:22
-1

There's an <Enter> event that is triggered when the mouse pointer enters a widget's space. Depending on how you're building your menu, you may be able to use it.

See http://www.pythonware.com/library/tkinter/introduction/events-and-bindings.htm for more

Rafe Kettler
  • 75,757
  • 21
  • 156
  • 151