I'm trying to create an application in wxpython that only uses a TaskBarIcon and no frames.
There is a question on this here, but that example doesn't work for me; it just exits with no error.
The code I've written below is a much simplified version of the code I'm working with:
import wx
class Systray_Icon(wx.TaskBarIcon):
def __init__(self):
icon = wx.Icon('yellow.ico', wx.BITMAP_TYPE_ICO)
self.SetIcon(icon, "Test")
self.Bind(wx.EVT_MENU, self.Destroy(), id=wx.ID_EXIT)
def CreatePopupMenu(self):
menu = wx.Menu()
menu.Append(wx.ID_EXIT, "Quit")
return menu
app = wx.App()
sysicon = Systray_Icon()
app.MainLoop()
I'm getting the following error:
$ python2 systray.py
Traceback (most recent call last):
File "systray.py", line 15, in <module>
sysicon = TaskBarIcon()
File "systray.py", line 6, in __init__
self.SetIcon(icon, "Test")
File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk2/wx/_windows.py", line 2841, in SetIcon
return _windows_.TaskBarIcon_SetIcon(*args, **kwargs)
TypeError: in method 'TaskBarIcon_SetIcon', expected argument 1 of type 'wxPyTaskBarIcon *'
So, my questions:
1: Why won't SetIcon accept my class? I've tried moving the SetIcon call to a function like in the question I linked, but it still doesn't work. I can fiddle around with it and probably get something to work, but I'd like to know the reason it won't work.
2: The question I linked to runs, but exits immediately. Is that because a TaskBarIcon won't hold MainLoop() open? What can I do about this?