how to set a menubar icon on mac osx using wx

前端 未结 4 1119
春和景丽
春和景丽 2020-12-05 21:52

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

相关标签:
4条回答
  • 2020-12-05 22:34

    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.

    0 讨论(0)
  • 2020-12-05 22:38

    As of wxPython 2.9.2.0 wx.TaskBarIcon will create a menubar icon now instead on OSX, so long as you call SetIcon.

    0 讨论(0)
  • 2020-12-05 22:42

    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.

    0 讨论(0)
  • 2020-12-05 22:45

    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:

    • you must import wx.adv
    • wx.TaskBarIcon becomes wx.adv.TaskBarIcon
    • wx.IconFromBitmap becomes wx.Icon

    This generates a status/notification/taskbar-type icon on other platforms as well.

    0 讨论(0)
提交回复
热议问题