Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add OSX menu bar icon with wxPython

I would like to add an icon to the OSX menu bar at the top of the screen using wxPython. I have tried wx.TaskBarIcon, which adds a System Tray icon in Windows, but this doesn't work - it changes the Dock icon for the app instead. Does anyone know how to do this?

like image 362
codebox Avatar asked May 12 '10 19:05

codebox


2 Answers

It seems that with wxPython2.9-osx-cocoa-py2.7 you can in fact put up a menubar icon. It looks like you can also call PopupMenu() on TaskBarIcon to attach a menu, which you should be able to use to create a full blown OSX menu bar application.

import wx

class TaskBarFrame(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, style=wx.FRAME_NO_TASKBAR |
                                              wx.NO_FULL_REPAINT_ON_RESIZE)

        self.tbicon = wx.TaskBarIcon()
        icon = wx.Icon('myicon.ico', wx.BITMAP_TYPE_ICO)
        self.tbicon.SetIcon(icon, '')


app = wx.App(False)
frame = TaskBarFrame(None)
frame.Show(False)
app.MainLoop()
like image 163
Heikki Toivonen Avatar answered Oct 11 '22 10:10

Heikki Toivonen


Answer provided here on Google Groups - in summary, you can't do it.

like image 25
codebox Avatar answered Oct 11 '22 12:10

codebox