Mouse Events Of Wxpython Taskbaricon On Mac Osx Are Not Triggering
We are using TaskBarIcon of WxPython 2.9 on Mac OSX 10.8.5, currently we have a requirement to grab all Left, Right and Double Click Events when user clicks on TaskBarIcon of our A
Solution 1:
Taskbar icon implementation is OS dependent. The following app binds all events supplied in wxPython so you can use it for testing.
import wx
from wx.lib.embeddedimage import PyEmbeddedImage
task = PyEmbeddedImage(
"iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAArxJ""REFUWIXl1z9oJGUYx/HPrvvP3SVmZYkkatYmJ1wTUmhp5YFFQC3kCq8RbAXBTrCxMoXClVdc""JwtiZxfRQgsRRNJsSBMxiPljdkl2WZPMMtmsxb17SfbmcicIjvg0v3mf9/fOvO+X531nhv97""ZCYTq6urc9BsNm/DxsbGq9Dtdqfg7OwsG1SSDofDK/ODwWAA/X6/BNl/fEl/My4SmIKlpaWf""oFarXYM4jnG+gkk9PT29sn+svV4PtNvtS8/+1wnkxhf5fP5D2NvbG0Kr1foE4jg+gVwudxNq""tVoe2u325xP3WoC5ublbsLOz823Ifx90THt4cVAqCOQgjuOXYXd396XQd3TRODU1dQNGo9FW""SH08ca93IYqiW6H9ZdA7V00gFQTOwvXbQY+SjMVi8Xk4ODj48SH9Dc6rHp3HmUCqCOw+xPME""HB8fPwuDweCPJFO5XJ6FQqEAeuON/4hIBYFHxRyUSqUc9Hq9RFKVSuUZyGTuH66JtTQZ/wkC""81Aul8ftnSRTtVp9mvN3A6LHmUD6CVQqlRc4r278nuQrFAoVyGbvr2mY5JuM9BNoNBqvQxRF""4/PityRfPp/PcmkXVJN8y8vLL8Lm5uavpJnAwsLCezAajd4KqfHKB0n+TCZzCMViEdTr9Teh""0+n8HCwjaLVad2Fra+sN0khgcXHxHTg8PLzN+TdhJpP5JViKQS+RyOfz69Dv91+B+fn5D2Bl""ZeUaNJvNJ2Ftbe25MOSMFBB44L+g0WisQ7vdvg6zs7Nge3v7DkRR9H6wXjrpZmZmbkC9Xv8a""Op17nwNRdM82ro1ut/spxHH8ESkg8EANlEqlH2B6evo6HB0ddSCKomawJO6C/f39b6BarX4B""xWLxJmSz2RGcnJx8BXEcfxaGnJACAg/UAOpBl4OuB10LeurqeCroa0H/DPrdRBspIPAXawn9""rf2GhSwAAAAASUVORK5CYII=")
classMainWindow(wx.Frame):
def__init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
self.panel = wx.Panel(self)
self.tbicon = wx.TaskBarIcon()
self.tbicon.SetIcon(task.GetIcon(), "Test")
self.tbicon.Bind(wx.EVT_TASKBAR_LEFT_DOWN, self.LD)
self.tbicon.Bind(wx.EVT_TASKBAR_LEFT_UP, self.LU)
self.tbicon.Bind(wx.EVT_TASKBAR_RIGHT_DOWN, self.RD)
self.tbicon.Bind(wx.EVT_TASKBAR_RIGHT_UP, self.RU)
self.tbicon.Bind(wx.EVT_TASKBAR_LEFT_DCLICK, self.LDC)
self.tbicon.Bind(wx.EVT_TASKBAR_RIGHT_DCLICK, self.LDC)
# This is a synonym for either wx.EVT_TASKBAR_RIGHT_DOWN # or UP depending on the platform, use this event macro # to catch the event which should result in the menu being # displayed on the current platform.
self.tbicon.Bind(wx.EVT_TASKBAR_CLICK, self.Click)
self.Bind(wx.EVT_CLOSE, self.Cleanup)
self.Show()
defClick(self, e):
print("Click")
e.Skip()
defLD(self, e):
print("LD")
e.Skip()
defLU(self, e):
print("LU")
e.Skip()
defRD(self, e):
print("RD")
e.Skip()
defRU(self, e):
print("RU")
e.Skip()
defLDC(self, e):
print("L-DClick")
e.Skip()
defRDC(self, e):
print("R-DClick")
e.Skip()
defCleanup(self, e):
self.tbicon.Destroy()
wx.Exit()
app = wx.App(False)
win = MainWindow(None)
app.MainLoop()
On Windows 7, for example:
- Left Down is emitted together with Left Up and not alone
- Right Down is emitted correctly
- Click is emitted with Right Up (Windows default for menu)
- Double Clicks work just fine
If it does not work on OS X or the behavior you get seems to be wrong for your platform, consider reporting a bug at http://trac.wxwidgets.org/.
Post a Comment for "Mouse Events Of Wxpython Taskbaricon On Mac Osx Are Not Triggering"