this are just some thoughts an advice on popping an xp style balloon tip over a
wx.TaskBarIcon. It is not a solution and it is not a question, but i'm putting
it here in case someone googles this in the future:
i've seen requests for having xp balloon tips popup over a tray icon and i've
seen it done using pure win32gui but i wanted to do it using wx.
the win32 api function to call is Shell_NotifyIcon and this function expects a
window handle and an icon handle.
the problem with popping a balloon over an icon added using wxTaskBarIcon is
that wxWindows creates a hidden window called wxTaskBarIconWindow to manage the
icons and the handle that is passed to Shell_NotifyIcon is the handle to this
window. But this window is not accessible in wxPython =(
i looked further in the code and couldnt' find an identifying characteristic for
this window. that is, the class name is the same as any other wx window, the id
is different on each instance of the app, and there's no title set on it.
so my cheesy way of figuring out which window is the TaskBarIconWindow is this:
* overide TaskBarIcon:
class MyTaskBarIcon(wx.TaskBarIcon):
def SetIcon(self, icon, msg=None):
wx.TaskBarIcon.SetIcon(self, icon, msg)
if self._tray_hwnd: # assume this was set to None in an init function
return # return if set because this means we've found the window
# otherwise, run through the windows in the app:
def cheese_enum(chwnd, ignored):
if len(win32gui.GetWindowText(chwnd)) == 0 and \
win32gui.GetWindowRect(chwnd) == (0,0,400,250):
self._tray_hwnd = chwnd # we found it
return True
robert cadena <robert.cadena <at> gmail.com> writes:
this are just some thoughts an advice on popping an xp style balloon tip over a
wx.TaskBarIcon. It is not a solution and it is not a question, but i'm putting
oops! i pressed tab and return on my browser. apologies. here is the complete
message:
···
----
this are just some thoughts an advice on popping an xp style balloon tip over a
wx.TaskBarIcon. It is not a solution and it is not a question, but i'm putting
it here in case someone googles this in the future:
i've seen requests for having xp balloon tips popup over a tray icon and i've
seen it done using pure win32gui but i wanted to do it using wx.
the win32 api function to call is Shell_NotifyIcon and this function expects a
window handle and an icon handle.
the problem with popping a balloon over an icon added using wxTaskBarIcon is
that wxWindows creates a hidden window called wxTaskBarIconWindow to manage the
icons and the handle that is passed to Shell_NotifyIcon is the handle to this
window. But this window is not accessible in wxPython =(
i looked further in the code and couldnt' find an identifying characteristic for
this window. that is, the class name is the same as any other wx window, the id
is different on each instance of the app, and there's no title set on it.
so my cheesy way of figuring out which window is the TaskBarIconWindow is this:
* overide TaskBarIcon:
class MyTaskBarIcon(wx.TaskBarIcon):
def SetIcon(self, icon, msg=None):
wx.TaskBarIcon.SetIcon(self, icon, msg)
if self._tray_hwnd: # assume this was set to None in an init function
return # return if set because this means we've found the window
# otherwise, run through the windows in the app:
def cheese_enum(chwnd, ignored):
# this is the cheesy part. the only somewhat distinguishable
# feature of the TaskBarIconWindow is that it has no title
# and its size is the default wx.Frame size. Read more
# at the end of this message
if len(win32gui.GetWindowText(chwnd)) == 0 and \
win32gui.GetWindowRect(chwnd) == (0,0,400,250):
self._tray_hwnd = chwnd # we found it
return True
return True
def showBalloon(self, title, text, duration=20):
if not self._tray_hwnd:
print "Tray not found yet"
So this works for my app because it will have few windows, and the policy is
that all windows, even if not shown, wil have a title. But it won't work
generally. So, i hope sometime in a future version there is some way to get at
this information from wxPython. Obviously only for msw.
if there already is a way to get at this info, please let me know. i'd rather
not have to use this method.
this are just some thoughts an advice on popping an xp style balloon tip over a
wx.TaskBarIcon. It is not a solution and it is not a question, but i'm putting
it here in case someone googles this in the future:
Consider adding it to the wxPython wiki, which provides a good home for thoughts and advice like this.
robert cadena <robert.cadena <at> gmail.com> writes:
So this works for my app because it will have few windows, and the policy is
that all windows, even if not shown, wil have a title. But it won't work
generally. So, i hope sometime in a future version there is some way to get at
this information from wxPython. Obviously only for msw.
It think it would probably be possible to add a GetHandle method in 2.7. wxGTK could have a similar need...
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!