I'm trying to create a simple application that resides in the Notification area or Taskbar/System Tray area. I want it to be cross platform so that's why I'm using wxPython.
The application works well under Windows and Linux but under Macintosh it fails to show the main window when clicking the TaskbarIcon. I'm not bothered by the fact that the TaskbarIcon appears in the dock. It's just that my application doesn't work without this.
Here's 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 upped.'; right clicking prints 'Right upped.', then the application exits. On Macintosh left clicking on the icon doesn't do anything except flashing the icon; right clicking prints 'Right upped.', then the application exits.