From: Thomas Thomas [mailto:thomas@eforms.co.nz]
Sent: October 9, 2006 9:56 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] saving the state of tree control
Hi Josiah,
Thanks for help… So copying and reassigning back is not option I suppose.
Why I need a copy is bcz the new state is a filtered down from the actual one.
It more like I have a tree with large set of files/folders and someone did a filtering for all the pdfs.
I need to give user option of going back to the all files state. At the moment when I do the filtering I delete all the existing items
add the filtered list of items. A view of the tree in windows explorer is similar to what I have…
What I do is separate the GUI from the “logic” in this case: I have an “abstract tree” that keeps track of what is selected, expanded, filtered out, etc. To each tree ctrl node, I attach a reference to the associated abstract tree node (via SetPyData) so I can save/read state of the abstract node in event handlers. Deep-copying that structure is easy, and I just need to walk through the tree control when going back to a previous state. Also, you may want to create a dictionary or list of the tree nodes, because walking through a tree is a major – I haven’t found a better way (other than the dictionary) than using GetFirstItem/GetNext/GetSibling etc, MAJOR pain – and many operations (such as going back to a previous state) don’t care what order you traverse the tree.
Oliver