setting a tooltip on auinotebook tab?

Hi,

I have this event triggered on hovering on an auinotebook tab:

class Notebook(aui.AuiNotebook):
  def __init__(self, parent, **kwargs):
    aui.AuiNotebook.__init__(self, parent, agwStyle = aui.AUI_NB_TOP |
aui.AUI_NB_TAB_MOVE | aui.AUI_NB_SCROLL_BUTTONS |
aui.AUI_NB_CLOSE_ON_ACTIVE_TAB, **kwargs)

  self.Bind(wx.EVT_MOTION, self.OnMouseOver, self)

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

  # display the tooltip if our title is not the same as our
original_args
  desc = None
  n = self.GetSelection()
  if n != -1:
    p = self.pages.get(self.GetPageText(n))
    if p is not None and p.s.original_line is not None:
      if p.display_name != p.s.original_line:
         desc = p.s.original_line

  self.SetToolTipString(desc or '')
  evt.Skip()

mouse over is triggered correctly and the Tooltip appears to set
without error (I set desc to not '')
but no tip appears?

a side question - in theory this should work for a non-active tab, but
how to I get a reference to tab that I am currently hovering over?

thanks,

jeff

Hi,

I have this event triggered on hovering on an auinotebook tab:

class Notebook(aui.AuiNotebook):
   def __init__(self, parent, **kwargs):
    aui.AuiNotebook.__init__(self, parent, agwStyle = aui.AUI_NB_TOP |
aui.AUI_NB_TAB_MOVE | aui.AUI_NB_SCROLL_BUTTONS |
aui.AUI_NB_CLOSE_ON_ACTIVE_TAB, **kwargs)

   self.Bind(wx.EVT_MOTION, self.OnMouseOver, self)

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

   # display the tooltip if our title is not the same as our
original_args
   desc = None
   n = self.GetSelection()
   if n != -1:
     p = self.pages.get(self.GetPageText(n))
     if p is not None and p.s.original_line is not None:
       if p.display_name != p.s.original_line:
          desc = p.s.original_line

   self.SetToolTipString(desc or '')
   evt.Skip()

mouse over is triggered correctly and the Tooltip appears to set
without error (I set desc to not '')
but no tip appears?

The tabs are implemented using a child window, so you would probably need to set the tooltip on that window instead of self.

a side question - in theory this should work for a non-active tab, but
how to I get a reference to tab that I am currently hovering over?

The AuiTabContainer class has a TabHitTest method that sounds promising.

···

On 3/8/12 12:27 PM, Jeff wrote:

--
Robin Dunn
Software Craftsman

so insted of self.SetToolTipString(desc)

the following work to create the tip on the correct 'tabl' window:

if n != -1:
  page_info = self._tabs.GetPage(n)
  ctrl, ctrl_idx = self.FindTab(page_info.window)
  if ctrl:
  ctrl.SetToolTipString(desc)

thanks Robin!

···

On Mar 8, 4:49 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 3/8/12 12:27 PM, Jeff wrote:

> Hi,

> I have this event triggered on hovering on an auinotebook tab:

> class Notebook(aui.AuiNotebook):
> def __init__(self, parent, **kwargs):
> aui.AuiNotebook.__init__(self, parent, agwStyle = aui.AUI_NB_TOP |
> aui.AUI_NB_TAB_MOVE | aui.AUI_NB_SCROLL_BUTTONS |
> aui.AUI_NB_CLOSE_ON_ACTIVE_TAB, **kwargs)

> self.Bind(wx.EVT_MOTION, self.OnMouseOver, self)

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

> # display the tooltip if our title is not the same as our
> original_args
> desc = None
> n = self.GetSelection()
> if n != -1:
> p = self.pages.get(self.GetPageText(n))
> if p is not None and p.s.original_line is not None:
> if p.display_name != p.s.original_line:
> desc = p.s.original_line

> self.SetToolTipString(desc or '')
> evt.Skip()

> mouse over is triggered correctly and the Tooltip appears to set
> without error (I set desc to not '')
> but no tip appears?

The tabs are implemented using a child window, so you would probably
need to set the tooltip on that window instead of self.

> a side question - in theory this should work for a non-active tab, but
> how to I get a reference to tab that I am currently hovering over?

The AuiTabContainer class has a TabHitTest method that sounds promising.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org