+ def DoGiveHelp(self, hit):
+ """ Gives tooltips and help in StatusBar. """
+
+ if not self.GetUseHelp():
+ return
+
+ shortHelp = hit.GetShortHelp()
+ if shortHelp:
+ self.SetToolTipString(shortHelp)
+ self._haveTip = True
+
+ longHelp = hit.GetLongHelp()
+ if not longHelp:
+ return
+
+ topLevel = wx.GetTopLevelParent(self)
+
+ if isinstance(topLevel, wx.Frame) and topLevel.GetStatusBar():
+ statusBar = topLevel.GetStatusBar()
+
+ if self._statusTimer and self._statusTimer.IsRunning():
+ self._statusTimer.Stop()
+ statusBar.PopStatusText(0)
+
+ statusBar.PushStatusText(longHelp, 0)
+ self._statusTimer = StatusBarTimer(self)
+ self._statusTimer.Start(_DELAY, wx.TIMER_ONE_SHOT)
+
+
+ def RemoveHelp(self):
+ """ Removes the tooltips and statusbar help (if any) for a button. """
+
+ if not self.GetUseHelp():
+ return
+
+ if self._haveTip:
+ self.SetToolTipString("")
+ self._haveTip = False
+
+ if self._statusTimer and self._statusTimer.IsRunning():
+ topLevel = wx.GetTopLevelParent(self)
+ statusBar = topLevel.GetStatusBar()
+ self._statusTimer.Stop()
+ statusBar.PopStatusText(0)
+ self._statusTimer = None
+
+
+ def RepaintOldSelection(self):
+ """ Repaints the old selected/hovered button. """
+
+ current = self._currentButton
+
+ if current == -1:
+ return
+
+ btn = self._vButtons[current]
+ if not btn.IsEnabled():
+ return
+
+ btn.SetStatus("Normal")
+
+
+ def OnStatusBarTimer(self):
+ """ Handles the timer expiring to delete the longHelp in the StatusBar. """
+
+ topLevel = wx.GetTopLevelParent(self)
+ statusBar = topLevel.GetStatusBar()
+ statusBar.PopStatusText(0)
+
+
+ def SetUseHelp(self, useHelp=True):
+ """ Sets whether or not shortHelp and longHelp should be displayed. """
+
+ self._useHelp = useHelp
+
+
+ def GetUseHelp(self):
+ """ Returns whether or not shortHelp and longHelp should be displayed. """
+
+ return self._useHelp
+
+