[wxpython-mac] Transparent systray icon in the Mac OS X dock
Gros Bedo
gros_bedo at hotmail.com
Thu Jun 26 16:25:53 PDT 2008
Hello,
I am currently porting an application to Linux and MacOSX. Everything works well (wxWidgets and wxPython are great for this matter) but I still have a problem with my systray icon. First, the icon isn't transparent, there is a black box background. Secondly, it doesn't show the application when I left-click on it.
For the first problem, after searching the whole web, I finally found one example which worked, and it simply is in the Demo folder of wxPython, in Main.py
Indeed, this demo application create an icon with a transparent background, but I can't replicate it at all with my icon. It seems the icon was converted with img2py first, but I would like to do the same with a real image. Here's a snippet of the code found in Main.py:
WXPdemo = PyEmbeddedImage(
"iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAWlJ"
"REFUWIW1V1sSwjAIBMebeBU9db2KZ8EPmxbCI4TUnXGskWaXDQktwhjErjERP4XRhER08iPi"
"5SKiyQR5JyI7xxB3j7wn5GI6V2hFxM0gJtjYANFBiIjQu7L/1lYlwR0QxLDZhE0II1+CtwRC"
"RI8riBva7DL7CC9VAwDbbxwKtdDXwBi7K+1zCP99T1vDFedd8FBwYd6BCAUXuACEF7QsbET/"
"FaHs+gDQw4vOLNHkMojAnTw8nlNipIiwmR0DCXJbjCXkFCAL23BnpQgRWt1EMbyujCK9AZzZ"
"f+b3sX0oSqJQ6EorFeT4NiL6Wtj0+LXnQAzThYoAAsN6ehqR3sHExmcEqGeFApQLcTvm5Kt9"
"wkHGgb+RZwSkyc1dwOcpCtCoNKSz6FRCUQ3o7Nn+5Y+Lg+y5CIXlcyAk99ziiQS32+svz/UY"
"vClJoLpIC8gi+VwwfDecEiEtT/WZTJDf94uk1Ru8vbz0cvoF7S2DnpeVL9UAAAAASUVORK5C"
"YII=")
def MakeIcon(self, img):
"""
The various platforms have different requirements for the
icon size...
"""
if "wxMSW" in wx.PlatformInfo:
img = img.Scale(16, 16)
elif "wxGTK" in wx.PlatformInfo:
img = img.Scale(22, 22)
# wxMac can be any size upto 128x128, so leave the source img alone....
icon = wx.IconFromBitmap(img.ConvertToBitmap() )
return icon
def __init__(self, frame):
wx.TaskBarIcon.__init__(self)
self.frame = frame
# Set the image
icon = self.MakeIcon(images.WXPdemo.GetImage())
self.SetIcon(icon, "wxPython Demo")
self.imgidx = 1
Here's my code:
icon = wx.Icon ('icon.ico', wx.BITMAP_TYPE_ANY)
self.tbicon.SetIcon (icon, sTip)
wx.EVT_TASKBAR_LEFT_UP (self.tbicon, self.OnTaskBarActivate)
I've tried many changes in Main.py to include my own icon, but without any success, I can't even manage to show it. For the second problem, I've put some code in self.OnTaskBarActivate to show the form, but it seems this function is never called on Mac OS X. Do I have to use another event to catch left click ?
My testing environment is Mac OS X 10.5 Leopard. I hope someone will be able to guide me for this problem, as after this my port will be finished ! :-)
_________________________________________________________________
Caroline vient de mettre à jour son profil Messenger ! Connectez-vous !
http://login.live.com/login.srf?wa=wsignin1.0&rpsnv=10&ct=1198837564&rver=4.0.1534.0&wp=MBI&wreply=http:%2F%2Fhome.services.spaces.live.com%2F&lc=1036&id=73625
More information about the wxpython-mac
mailing list