Tooltips on CustomTreeCtrl (HyperTreeList) leaves

Hi, ALL,

What else is required to do subj besides handling wx.EVT_TREE_ITEM_GETTOOLTIP?

I have Windows XP SP3, python-2.7, wxPython-2.9.5.

It looks like I need something else besides handling this event, but what?

Running the demo and hovering the mouse over the item does not produce the tooltip…

Thank you.

This is what I do:

class MyPanel(wx.Panel):

A lot of initialization

self.hypertree = HyperTreeList( self, -1 )

#populate tree with items

self.hypertree.Bind( wx.EVT_TREE_ITEM_GETTOOLTIP, self.OnTreeToolTip )

def OnTreeToolTip(self, evt):

#define and display the tooltip

Problem is the code never hits the OnTreeToolTip() function.

Runnung under the debugger the code in hypertreelist.py gets executed when I hover the mouse over the item, then it

sends the wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP, which is bound by wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP, 1) and it gets processed by calling customtreectrl.py OnGetToolTip()

which issues the command event.Veto() unconditionally.

And so the code never reaches my own handler,

I believe the same goes to the HTL demo.

Thank you.

···

On Sat, Sep 28, 2013 at 1:51 AM, Igor Korot ikorot01@gmail.com wrote:

Hi, ALL,

What else is required to do subj besides handling wx.EVT_TREE_ITEM_GETTOOLTIP?

I have Windows XP SP3, python-2.7, wxPython-2.9.5.

It looks like I need something else besides handling this event, but what?

Running the demo and hovering the mouse over the item does not produce the tooltip…

Thank you.

Igor Korot wrote:

This is what I do:
class MyPanel(wx.Panel):
# A lot of initialization
      self.hypertree = HyperTreeList( self, -1 )
#populate tree with items
     self.hypertree.Bind( wx.EVT_TREE_ITEM_GETTOOLTIP, self.OnTreeToolTip )
def OnTreeToolTip(self, evt):
#define and display the tooltip
Problem is the code never hits the OnTreeToolTip() function.
Runnung under the debugger the code in hypertreelist.py gets executed
when I hover the mouse over the item, then it
sends the wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP, which is bound by
wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP, 1) and it gets
processed by calling customtreectrl.py OnGetToolTip()
which issues the command event.Veto() unconditionally.
And so the code never reaches my own handler,

The issue is due to the fact that HyperTreeList does not derive directly from CustomTreeCtrl. Instead it has a CustomTreeCtrl as a child of the HTL and the event binding you do for _GETTOOLTIP will not be seen because you are binding it to a window further up the containment hierarchy. In order to have your event handler called first then you'll need to use self.hypertree.GetMainWindow().Bind(...) to bind your handler directly to the tree control.

It would probably be a good idea to have the HTL class intercept and resend this event itself so using self.hypertree.Bind would do the right thing. If somebody wants to make a change like this I'll review a patch.

···

--
Robin Dunn
Software Craftsman

Hi, Robin,

Igor Korot wrote:

This is what I do:
class MyPanel(wx.Panel):

A lot of initialization

  self.hypertree = HyperTreeList( self, -1 )

#populate tree with items
self.hypertree.Bind( wx.EVT_TREE_ITEM_GETTOOLTIP, self.OnTreeToolTip )
def OnTreeToolTip(self, evt):
#define and display the tooltip
Problem is the code never hits the OnTreeToolTip() function.

Runnung under the debugger the code in hypertreelist.py gets executed
when I hover the mouse over the item, then it
sends the wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP, which is bound by
wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP, 1) and it gets

processed by calling customtreectrl.py OnGetToolTip()
which issues the command event.Veto() unconditionally.
And so the code never reaches my own handler,

The issue is due to the fact that HyperTreeList does not derive directly from CustomTreeCtrl. Instead it has a CustomTreeCtrl as a child of the HTL and the event binding you do for _GETTOOLTIP will not be seen because you are binding it to a window further up the containment hierarchy. In order to have your event handler called first then you’ll need to use self.hypertree.GetMainWindow().Bind(…) to bind your handler directly to the tree control.

Thank you. You are a lifesaver.

It would probably be a good idea to have the HTL class intercept and resend this event itself so using self.hypertree.Bind would do the right thing. If somebody wants to make a change like this I’ll review a patch.

In the meantime it would be nice to change the HTL demo to reflect this as right now the demo (at least in 2.9.5) binds this event to the HTL itself.

Thank you.

···

On Tue, Oct 1, 2013 at 9:38 AM, Robin Dunn robin@alldunn.com wrote:


Robin Dunn
Software Craftsman
http://wxPython.org


You received this message because you are subscribed to the Google Groups “wxPython-users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.