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.
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.
#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.
–
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.