I Hope someone can point me in the right direction on using the HyperTreeList with a virtual data source. After struggling with it for awhile isn’t obvious to me how to go about this.
Using a wx.ListCtrl is quite straightforward - SetItemCount, and override .OnGetItemText to collect the items from the datamodel and it just seems to work.
How do I tell HyperTreeList about the items it needs to manage ?
Do I have to use the treemixin.VirtualTree ?
in my struggles, I have over-ridden the .OnGetItemText() method, however, the item parameter is only ever set to ‘None’.
– how/where do I get it to reference the other items in the model ?
I Hope someone can point me in the right direction on using the HyperTreeList with a virtual data source. After struggling with it for awhile isn't obvious to me how to go about this.
Using a wx.ListCtrl is quite straightforward - SetItemCount, and override .OnGetItemText to collect the items from the datamodel and it just seems to work.
How do I tell HyperTreeList about the items it needs to manage ?
Do I have to use the treemixin.VirtualTree ?
in my struggles, I have over-ridden the .OnGetItemText() method, however, the item parameter is only ever set to 'None'.
-- how/where do I get it to reference the other items in the model ?
The way this is typically done with wx.TreeCtrl (and I assume that HyperTreeList will work similarly) is to delay loading items into the tree until the parent node of those items is expanded. IOW, you call SetItemHasChildren on the parent node, but don't actually load the children. Then when the ITEM_EXPANDING event is fired for that parent node you add the children at that point in time (calling SetItemHasChildren for those child items that also have children.) If desired you can also remove children as the parent node is collapsed in order to remove those items from memory.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
The way this is typically done with wx.TreeCtrl (and I assume that HyperTreeList will work similarly) is to delay loading items into the tree until the parent >node of those items is expanded. IOW, you call SetItemHasChildren on the parent node, but don't actually load the children. Then when the >ITEM_EXPANDING event is fired for that parent node you add the children at that point in time (calling SetItemHasChildren for those child items that also have >children.) If desired you can also remove children as the parent node is collapsed in order to remove those items from memory.
--
Robin Dunn
Thanks Robin, that makes sense ... BUT ... does that mean that the
parents have to all be loaded?
IOW if I have a list of 5,000 items that are parents, is there any way
that these can attached to the tree and loaded 'virtually' as needed.
I really like the way that the wx.ListCtrl handles this pattern and
when I saw that HyperTreeList supports a style TR_VIRTUAL I
hoped/assumed that it would allow detaching the data model from the
actual view.
NOTE that the way we are using the tree is to present a list of items
and then allow the user to add child elements to these items. So not
all of the 5000 'parent' items will end up with children ... as a
matter of fact maybe only 10-15 of the parents will end up with
children.
You can take a look at treemixin.VirtualTree and see whether it works
with HyperTreeList (it might not since the HyperTreeList is newer).
But the treemixin.VirtualTree is not virtual in the way that you
desire, i.e. it does not postpone displaying offscreen nodes (because
that is quite a bit harder with tree ctrls than with list ctrls).
Cheers, Frank
···
2009/4/15 geoff <imageguy1206@gmail.com>:
The way this is typically done with wx.TreeCtrl (and I assume that HyperTreeList will work similarly) is to delay loading items into the tree until the parent >node of those items is expanded. IOW, you call SetItemHasChildren on the parent node, but don't actually load the children. Then when the >ITEM_EXPANDING event is fired for that parent node you add the children at that point in time (calling SetItemHasChildren for those child items that also have >children.) If desired you can also remove children as the parent node is collapsed in order to remove those items from memory.
--
Robin Dunn
Thanks Robin, that makes sense ... BUT ... does that mean that the
parents have to all be loaded?
IOW if I have a list of 5,000 items that are parents, is there any way
that these can attached to the tree and loaded 'virtually' as needed.
Thanks for this Frank.
I was getting the feeling that it wasn't 'virtual' in the same sense
as the wx.ListCtrl ... but one can always hope ... !
I did review treemixin.VirtualTree and there was and earlier post from
someone that got it to work. I will review it again more closely and
see if it makes sense to use this with our existing data model.
g.
···
On Wed, Apr 15, 2009 at 12:31 PM, Frank Niessink <frank@niessink.com> wrote:
2009/4/15 geoff <imageguy1206@gmail.com>:
The way this is typically done with wx.TreeCtrl (and I assume that HyperTreeList will work similarly) is to delay loading items into the tree until the parent >node of those items is expanded. IOW, you call SetItemHasChildren on the parent node, but don't actually load the children. Then when the >ITEM_EXPANDING event is fired for that parent node you add the children at that point in time (calling SetItemHasChildren for those child items that also have >children.) If desired you can also remove children as the parent node is collapsed in order to remove those items from memory.
--
Robin Dunn
Thanks Robin, that makes sense ... BUT ... does that mean that the
parents have to all be loaded?
IOW if I have a list of 5,000 items that are parents, is there any way
that these can attached to the tree and loaded 'virtually' as needed.
You can take a look at treemixin.VirtualTree and see whether it works
with HyperTreeList (it might not since the HyperTreeList is newer).
But the treemixin.VirtualTree is not virtual in the way that you
desire, i.e. it does not postpone displaying offscreen nodes (because
that is quite a bit harder with tree ctrls than with list ctrls).
Thanks for this Frank.
I was getting the feeling that it wasn't 'virtual' in the same sense
as the wx.ListCtrl ... but one can always hope ... !
Your hope will be answered in 2.9 where we have the DataViewCtrl that is totally model driven and does ask the model for values to display on-demand. On OSX and GTK it is a native widget and on Windows it is a generic implementation. It can essentially be used for anything that you would currently use a wx.TreeCtrl, wx.ListCtrl (in report mode only) or a TreeListCtrl for now. I've been working lately on some samples for the demo, you can get a sneak peek at them here: