[wxPython] Finding wxTreeItemId from data associated to a wxTreeItemData

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] Finding wxTreeItemId from data associated to a wxTreeItemData

Cavanaugh, Craig
I've been browsing through the list archive and haven't found anything.

Is there an "easy / existing" way of getting a wxTreeItemId from a reference
to data that was associated to a wxTreeItemData?

i.e   treeItem = findData(wxTree, data)

Otherwise, I assume I will have the search the tree for the matching data
using something like to following:

Start at top of tree
   Look at children <--- recursion?
        data = self.tree.GetPyData(treeItem)
        if data is goodData:
            # found it, do something with the treeItem

What I'm trying to do is append items to a tree.  The tree is a
representation of a list of objects that can contain lists of objects, and
so on. (as far as I know, this is only limited by memory).  I need to update
the tree when the list changes, but I do not know what the treeItemId is and
I do not want to store the treeItemId with the real data.

My other option is to remove all items from the tree and then rebuild it
using the updated list.  I'm not worried about speed so much as I'm worried
about display flicker (It makes it look slow)

thanks,
Craig  


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Finding wxTreeItemId from data associated to a wxTreeItemData

Robin Dunn
> I need to update
> the tree when the list changes, but I do not know what the treeItemId is
and
> I do not want to store the treeItemId with the real data.
>

This is what I would suggest.  Or perhaps using an intermediate dictionary or
something to map your data objects to tree IDs.

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users