From: Alex T. <al...@tw...> - 2005-12-15 12:16:42
|
XXXXXXXXXXX wrote: > Thanks for checking. I've got the same setup here except for the > PythonCard version. > > But I was a bit hasty in my analysis...it appears that the tool tip > stops working as soon as I let the pointer cross the actual tree > element within the control. If I keep the pointer within the blank > area of the control then I can move it onto other controls and back > and the tip reappears. Touch the tree...tip no more. > Oh - you mean you put actual data in it :-) I didn't get that far - just created a tree control and checked that a tooltip then worked. > I'll try upgrading like you suggest. Won't help. It's not a bug, it's a feature :-) At least on Windows, you can set the tooltip individually for each item (from the WX docs it does look as though this is Windows only, but I'm not in a position to try it on other systems just now). This isn't exposed through PythonCard, so you need to use the wx event system directly. I changed the minimalTree sample as below (changed line and section marked in comments). The "OnItemExpanded" isn't needed - but it was the one I used for first experiments. For this example, I just always set the same tooltip, but you could customize > #!/usr/bin/python > > """ > __version__ = "$Revision: 1.6 $" > __date__ = "$Date: 2004/05/05 16:53:27 $" > """ > > from PythonCard import model > import wx -- ADDED THIS LINE > > # events > # itemActivated, itemExpanding, itemExpanded, > # selectionChanging, selectionChanged > > class Minimal(model.Background): > > def on_initialize(self, event): > tree = self.components.tree > root = tree.addRoot("1") > tree.setItemHasChildren(root, 1) > tree.selectItem(root) > -- START OF NEW SECTION > self.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.OnItemExpanded, > self.components.tree) > self.Bind(wx.EVT_TREE_ITEM_GETTOOLTIP, self.OnItemSetTooltip, > self.components.tree) > > def OnItemExpanded(self, event): > print "expanded", event.GetItem() > pass > > def OnItemSetTooltip(self, event): > print "gettooltip", event.GetItem() > event.SetToolTip("this is the new tooltip for all items") > pass > -- END OF NEW SECTION > > def on_tree_itemExpanding(self, event): > tree = self.components.tree > item=event.item > # This event can happen twice in the self.Expand call > if tree.isExpanded(item): > return > obj = int(tree.getItemText(item)) > if tree.getChildrenCount(item, 0) == 0: > lst = [obj * 2, (obj *2) + 1] > for o in lst: > new_item = tree.appendItem(item, str(o)) > tree.setItemHasChildren(new_item, 1) > event.skip() > > > if __name__ == '__main__': > app = model.Application(Minimal) > app.MainLoop() -- Alex Tweedly http://www.tweedly.net -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.371 / Virus Database: 267.13.13/200 - Release Date: 14/12/2005 |