Search code examples
pythonwxpythonmenubarwxwidgets

wx top level menubar event (python)


Is there any way in wxPython to capture a click on an item on the menubar without any childeren.

I.e. with menu structure

  • File
    • Save
    • Quit
  • Spam

I am able to capture events for clicking the save or quit item but am unsure on how I can capture the event for clicking spam


Solution

  • @uhz solution almost works, but I wouldn't recommend it. There must be a reason why clickable top-level menu items are not permitted. Under my environment (Debian, wx 2.8) his solution develops strange behavior, like triggering the event by hovering the item.
    You're usecase is more the one of a toolbar, I suggest you use one here. One more time I can suggest a look a the examples at zetcode (section toolbars) if you're not familiar with them.