Search code examples
pythonwxpython

wxPython showing help upon mouse focus


I wonder if there is any easy way to popup help (stickies style) upon focusing the mouse on a wx.Button for a second or two. thanks


Solution

  • I believe you are looking for wx.ToolTip. An example:

    import wx
    
    class MyFrame(wx.Frame):
      def __init__(self, title, *args, **kwargs):
        super(MyFrame, self).__init__(None, title=title, *args, **kwargs)
        panel  = wx.Panel(self)
        button = wx.Button(panel, label="Button")
        tooltip = wx.ToolTip("Try to click this button")
        button.SetToolTip(tooltip)
    
    class MyApp(wx.App):
      def OnInit(self):
        self.frame = MyFrame("Example")
        self.frame.Show()
        return True
    
    MyApp(False).MainLoop()
    

    wx.ToolTip

    There are some methods you can use for controlling the tip.