Keyboard access to TaskBarIcon with ShowBalloon

Hi! Just discovered this group while searching for solutions, I hope you might be able to help me.

Accessing a taskbar icon through the keyboard is quite reasonable - the keyboard presses are translated to mouse events, but that’s good enough. The problem is, this all goes out the window after calling ShowBalloon.

I’ve found that I can restore the events by removing the icon and setting it again. The problem with this solution is that I have to wait for the balloon notification to time out first, because removing the icon also kills the balloon. So for the entire duration of the notification, keyboard access is essentially disabled.

Is there a better fix for this problem?

Thanks!

Here’s an outline of what I ended up with, for reference:

class MyTaskBarIcon(wx.TaskBarIcon):

def __init__(self, menu, *args, **kwds):

    wx.TaskBarIcon.__init__(self, *args, **kwds)

    self.Bind(wx.EVT_TASKBAR_CLICK, lambda evt: self.PopupMenu(menu))

    self.Bind(wx.EVT_TASKBAR_BALLOON_TIMEOUT, lambda evt: self._ResetIcon())

def SetIcon(self, icon, tooltip=""):

    self._icon = icon

    self._tooltip = tooltip

    wx.TaskBarIcon.SetIcon(self, icon, tooltip)

def _ResetIcon(self):

    self.RemoveIcon()

    self.SetIcon(self._icon, self._tooltip)