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

我们两清 提交于 2019-12-11 14:19:09

问题


Nothing to add


回答1:


Do you want an event when your menu is opened? Use EVT_MENU_OPEN(func) (wxMenuEvent). But it's not in particular precise. As the documentation says, it is only sent once if you open a menu. For another event you have to close it and open another menu again. I.e in between, you can open other menus (by hovering other items in the menubar), and the event won't be sent again.

What do you need this for? Probably there is another way to do it, instead of listening for this kind of event.

If you want an event for all items of a menu, use EVT_MENU_RANGE(id1, id2, func) (it's using wxCommandEvent). All IDs starting from id1 up to and including id2 will be connected to the given event handler. Using a range instead of connecting each item separate will provide for better performance, as there are fewer items in the event-handler list.



来源:https://stackoverflow.com/questions/300032/is-it-possible-to-bind-an-event-against-a-menu-instead-of-a-menu-item-in-wxpytho

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!