hi, i am writing an app where a treeCtrl may sometimes need to be destroyed and recreated (with minimal changes). that’s fine, but what if i want to be real clever and have the re-created treeCtrl appear with the last-selected item expanded?
i have tried this with something like:
def onReload(self, event):
‘reload all the xmldata’
xmlData = self.getXMLData(reload=1)
if self.parentsTreeFrame and self.parentsTreeFrame.IsShown():
selection = self.parentsTreeFrame.tree.GetSelection()
data = self.parentsTreeFrame.tree.GetPyData(selection) #print self.parentsTreeFrame.tree.GetPyData(selection).GetId()
id = wxTreeItemData(data).GetId() #print selection, data, id
self.onCloseParentTreeWindow()
self.showParentsTreeFrame(event=None, reload=0)
if selection:
self.parentsTreeFrame.tree.EnsureVisible(id)
…
to attempt to get this to work, i had to associate wxTreeItemData objects with each node in the tree. something like:
anway, that does not seem to work. i guess the wxTreeItem pointer changes when i reconstruct the tree, so trying to select by recreating that from an old wxTreeItemData object doesn’t seem to work. is there another way of doing this? am i way off course here?
Can't you avoid destroying and recreating the tree,
instead just modifying the items you need to change?
I realize that it's probably easier to rebuild it
from scratch than to traverse it and see where we need
to add or remove nodes, but I think this is the way
to go.
···
At 13:40 2002-09-20 -0700, Andrew Yinger wrote:
hi, i am writing an app where a treeCtrl may sometimes need to be destroyed and recreated (with minimal changes). that's fine, but what if i want to be real clever and have the re-created treeCtrl appear with the last-selected item expanded?
i wish it was that easy -- i have reparse the xml and recreate the tree from
scratch. unfortunately, there is no way around this -- the xml parsing is
extremely flexible and allows for a complete redefinition of the tree.
···
----- Original Message -----
From: "Magnus Lycka" <magnus@thinkware.se>
To: <wxpython-users@lists.wxwindows.org>
Sent: Friday, September 20, 2002 2:18 PM
Subject: Re: [wxPython] wxTreeCtrl question
At 13:40 2002-09-20 -0700, Andrew Yinger wrote:
>hi, i am writing an app where a treeCtrl may sometimes need to be
>destroyed and recreated (with minimal changes). that's fine, but what if
>i want to be real clever and have the re-created treeCtrl appear with the
>last-selected item expanded?
Can't you avoid destroying and recreating the tree,
instead just modifying the items you need to change?
I realize that it's probably easier to rebuild it
from scratch than to traverse it and see where we need
to add or remove nodes, but I think this is the way
to go.
Ok, this worked with 2.3.2, but fails with 2.3.3.
Windows 2000 and Python 2.2.1.
I'm in the middle of a wxGrid, and press PageUp.
I then get:
...dynarray.h(468): assert "uiIndex < m_nCount" failed,
followed by unknown s/w exception in python.exe
Earlier today I made a fix for what is probably a different manifestation of this same problem. <sigh> Looks like I'll be doing a 2.3.3.2 sooner than I expected...
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!