[wxPython] wxTreeCtrl - weird stuff

Hi all,

I don't know if this was asked before (found nothing in archives), but I
have the following problem with a wxTreeCtrl:

I'm building the tree _completely_ upon program startup (i.e. all nodes
are created 'at once', not onExpand or onCollapse). Now if I call
GetPyData(event.GetItem()) when an item is selected[1], the returned value
is _always_ the last object in the tree, i.e. the last child node of the
appropriate parent node that does not have any other children. I'd use the
source supplied in the demo (pyTree.py), but the data for the tree is a
LDAP query, so it might take some time to build a sub-tree upon expansion
of one of the nodes... If I "print" the objects that are beeing used for
AppendItem during the creation of child nodes I _do_ get the right
values... any hints what I might do wrong?

any help is greatly appreciated,
Igor

footnotes:
[1]: EVT_TREE_ITEM_ACTIVATED(self, self.GetId(), self.OnTreeSelChanged)

I'm building the tree _completely_ upon program startup (i.e. all nodes
are created 'at once', not onExpand or onCollapse). Now if I call
GetPyData(event.GetItem()) when an item is selected[1], the returned value
is _always_ the last object in the tree, i.e. the last child node of the
appropriate parent node that does not have any other children. I'd use the
source supplied in the demo (pyTree.py), but the data for the tree is a
LDAP query, so it might take some time to build a sub-tree upon expansion
of one of the nodes... If I "print" the objects that are beeing used for
AppendItem during the creation of child nodes I _do_ get the right
values... any hints what I might do wrong?

How are you creating the data objects attached to the tree items? Any
chance you are reusing the same object each time?

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!

I actually wrote the last two lines as an answer for this particular
question 'cos that's what I thought first of :slight_smile: I have an extra class that
handles the LDAP data, the items for child nodes are instances of this
class. I'm pretty sure, the objects that are created are not the same,
"vars(obj)" and "print obj" return expected values for each instance (i.e.
the right one)...

···

On Wed, 23 Jan 2002 16:09:55 -0800 "Robin Dunn" <robin@alldunn.com> wrote:

> of one of the nodes... If I "print" the objects that are beeing used
> AppendItem during the creation of child nodes I _do_ get the right
> values... any hints what I might do wrong?

How are you creating the data objects attached to the tree items? Any
chance you are reusing the same object each time?