Is it possible to bind an event to a menu instead of a menu item in wxPython?

Nothing to add

0


source to share


1 answer


Need an event when the menu opens? Use EVT_MENU_OPEN(func)

( wxMenuEvent

). But this is not particularly accurate. As the documentation says, it only dispatches once if you open the menu. For another event, you need to close it and reopen another menu. In the meantime, you can open other menus (by hovering over other items in the menu bar) and the event will no longer be dispatched.

Why do you need it? Perhaps there is another way to do this, instead of listening to such an event.



If you want an event for all menu items use EVT_MENU_RANGE(id1, id2, func)

(using wxCommandEvent

). All identifiers starting with id1

and inclusive id2

will be connected to this event handler. Using a range instead of concatenating each individual item will provide better performance because there are fewer items in the list of event handlers.

+2


source







All Articles