Reputation: 1650
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 the Dock. On Windows, wxTaskBarIcon creates a Systray icon and associated menu, and I would think that on mac osx it would create a menubar icon, I guess not.
Upvotes: 6
Views: 5485
Reputation: 747
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.
Upvotes: 1
Reputation: 6730
As of wxPython 2.9.2.0 wx.TaskBarIcon
will create a menubar icon now instead on OSX, so long as you call SetIcon
.
Upvotes: 1
Reputation: 24922
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.
Upvotes: 2
Reputation: 19930
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.
Upvotes: 4