Hi all,
I try to make a class that will put an icon in the windows tray.
I do the following :
---8<-----------------------------------------
from wxPython.wx import *
ID_ICON_TIMER = 2000
class TestTray :
def __init__ (self) :
self.trayIcon = wxTaskBarIcon ()
icon = wxIcon ("BTDTrayIcon.ico", wxBITMAP_TYPE_ICO)
self.trayIcon.SetIcon (icon, "lalala")
# connect the eventhandlers for the tray popup menu
EVT_TASKBAR_LEFT_DCLICK (self.trayIcon, self.OnClick)
def OnClick (self, evt) :
self.iconTimer = wxTimer (self, ID_ICON_TIMER)
EVT_TIMER (self, ID_ICON_TIMER, self.BlinkIcon)
self.iconTimer.Start (1000)
def BlinkIcon (self, evt) :
print " -->> BLINK <<-- "
class MyApp (wxApp) :
def OnInit (self) :
test = TestTray ()
return true
def main () :
app = MyApp ()
app.MainLoop ()
if __name__ == '__main__' :
main ()
---8<-----------------------------------------
And the problem I have is that the icon appear on second and diseppear because
the program ends... Then I think I'm not in the eventloop
But if I try to derive my class from wxEvtHandler, that I guess would maybe
solve the problem, it make an error that I don't have time to read because the
stdout/stderr windows on windows is only displayed when the programs run (And
I don't succeed on redirecting it in a file). But I think the error text is
somewhere similare to the one I have when trying to use wxTimer :
Traceback (most recent call last):
File "TrayTest.py", line 22, in OnClick
self.iconTimer = wxTimer (self, self.ID_ICON_TIMER)
File "C:\Python22\Lib\site-packages\wxPython\wx.py", line 1557, in __init__
self.SetOwner(evtHandler, id)
File "C:\Python22\Lib\site-packages\wxPython\misc2.py", line 353, in
SetOwner
val = apply(misc2c.wxPyTimer_SetOwner,(self,) + _args, _kwargs)
TypeError: Type error in argument 2 of wxPyTimer_SetOwner. Expected
_wxEvtHandler_p.
Could someone help me with some hints about which parent class to use or
anything else...
Thanks,
-philippe