-1

I'm creating a GUI using wxPython that uses the wx.Notebook widget. Since I removed the labels on the Notebook tabs for design purposes, I would like to add tooltips for each tab individually that show the tab's purpose.

I thought I could use the AddPage() method of the Notebook class. But it only returns bool values, so that I cannot use the SetToolTip() method for either tab. How would I go about doing that?

maxTwo
  • 33
  • 7
  • Please [edit] to add meaningful code and a problem description here. Posting a [Minimal, Complete, Verifiable Example](http://$SITEURL$/help/mcve) that demonstrates your problem would help you get better answers. Thanks! – anothernode Apr 20 '18 at 13:49

1 Answers1

0

This is not something that is built-in to the wx.Notebook widget. You could probably do it yourself by binding to wx.EVT_MOTION and checking you mouse's position to determine when to set a tooltip.

The AUINotebook might be a better choice since it has a TabHitTest method. Someone on the wxPython group mentioned a way to add tooltips to it here: http://wxpython-users.1045709.n5.nabble.com/setting-a-tooltip-on-auinotebook-tab-td5548750.html

Here's the code they ended up using in the mouse over event handler:

def OnMouseOver(self, evt):
    """ mouse over on a tab """

    desc = None
    n    = self.GetSelection()
    if n != -1:
        page_info = self._tabs.GetPage(n)
        ctrl, ctrl_idx = self.FindTab(page_info.window)
        if ctrl:
            ctrl.SetToolTipString(desc)
Mike Driscoll
  • 32,629
  • 8
  • 45
  • 88