I could not find any pointers on how to create a menubar icon on OSX using wx. I originally thought that the wxTaskBarIcon class would do, but it actually creates an icon on
You have to set wxTaskBarIconType
to STATUSITEM
, not DOCK
. The Cocoa APIs for this are NSStatusBar
and NSStatusItem
; here's the code in wxWidgets that calls to them.
As of wxPython 2.9.2.0 wx.TaskBarIcon
will create a menubar icon now instead on OSX, so long as you call SetIcon
.
This post by Robin Dunn, the creator of wxPython, explains that wxPython doesn't support menubar icons on mac yet. They only support the Dock.
There is an example on wiki.wxpython.org that puts an icon in the "status menus" section (right-hand side) of the macOS menu bar (ignore the page title): https://wiki.wxpython.org/Custom%20Mac%20OsX%20Dock%20Bar%20Icon
It works for me with macOS High Sierra (10.13.3) running python 2.7.14 (installed using miniconda) with wxpython 3.0.0.0 osx-cocoa (classic).
Similarly, it works with python 3.6.4 and wxpython 4.0.1 osx-cocoa (phoenix); minor code changes required:
This generates a status/notification/taskbar-type icon on other platforms as well.