I am trying to create a simple application that is in the notification area or taskbar / system tray area. I want it to be cross platform, so I use wxPython.
The application works well under Windows and Linux, but under Macintosh it does not display the main window when you click TaskbarIcon. I'm not bothered by the fact that TaskbarIcon appears in the dock. It is just that my application does not work without this.
Here is some simplified code that can reproduce the problem:
from views import embimgs import wx class MyTaskBarIcon(wx.TaskBarIcon): def __init__(self, app): wx.TaskBarIcon.__init__(self) self.app = app self.Bind(wx.EVT_TASKBAR_LEFT_UP, self.on_left_up) self.Bind(wx.EVT_TASKBAR_RIGHT_UP, self.on_right_up) def on_left_up(self, evt): print 'Left upped!' def on_right_up(self, evt): print 'Right upped!' self.app.ExitMainLoop() def main(): app = wx.PySimpleApp() mti = MyTaskBarIcon(app) mti.SetIcon(wx.IconFromBitmap(embimgs.logo64.GetBitmap())) app.MainLoop() app.Destroy() if __name__ == '__main__': main()
On Windows and Linux, left-clicking on the icon prints "Left up up."; Right-click βTop to Topβ. Then the application terminates. On a Macintosh, left-clicking on an icon does nothing but blinking; right click up. Then the application terminates.
source share