question concerning wxTreeCtrl and items

Hi Andrea!

This did the job! Thank you for your help!

regards
Oliver

             andrea.gavana@agi
             p.it
                                                                        To
             30.03.2005 15:57 wxPython-users@lists.wxwidgets.org
                                                                        cc
                                                                           
             Please respond to Subject
             wxPython-users@li Rif: [wxPython-users] question
             sts.wxwidgets.org concerning wxTreeCtrl and items
                                                                           
Hello Oliver,

      if you know what is your list (that is stored as PyData in the
treectrl items), you can scan all the treectrl and find which item has the
same PyData as your list. Regarding your code, I would store the reference
of every child in a separate list (this will be clearer after), like in
this example (all the children are store in the list self.mychildren):

def SortAfterSamples(self):
        """
        Populates the wxTreeCtrl by sorting after:
            1. samples
            2. assessors
            3. replicates
        """
        self.root = self.tree_ctrl_1.AddRoot('Sensory data')
        self.tree_ctrl_1.SetPyData(self.root, None)

        self.mychildren = []

        for samples in self.SampleList:
            child = self.tree_ctrl_1.AppendItem(self.root, samples)
            self.tree_ctrl_1.SetPyData(child, [samples])

            self.mychildren.append(child)

            for assessors in self.AssessorList:
                grandChild = self.tree_ctrl_1.AppendItem(child, assessors)
                self.tree_ctrl_1.SetPyData(grandChild, [samples,
assessors])

                self.mychildren.append(grandChild)

                for replicates in self.ReplicateList:
                    greatGrandChild =
self.tree_ctrl_1.AppendItem(grandChild, replicates)
                    self.tree_ctrl_1.SetPyData(greatGrandChild, [samples,
assessors, replicates])

                       self.mychildren.append(greatGrandChild)

Now, if I understood you correctly, you could do something like:

for child in self.mychildren:
      MyPyData = self.tree_ctrl_1.GetPyData(child)

      if MyPyData == MySpecificList:
            return child

And you get the item in which your MySpecificList is stored...

Hope to have correctly understood.
HTH.

Andrea.

···

_______________________________________________
Andrea Gavana
Reservoir Engineer
MOGI ? Reservoir Characterization and Modeling Dept.
ENI S.p.A. ? Exploration & Production Division
Via Emilia, 1 ? 20097 San Donato Milanese (MI) ? Italy
Phone: +39 02 520 62972
Fax: +39 02 520 61824
E-mail: andrea.gavana@agip.it
Updated Internet Site: http://xoomer.virgilio.it/infinity77/
____________________________________________________

Eni S.p.A.
Sede legale in Roma,
Piazzale Enrico Mattei 1, 00144 Roma
Tel. centralino: +39 06598.21
www.eni.it
Capitale sociale € 4.002.934.326 i.v.
Registro Imprese di Roma,
Codice Fiscale 00484960588
Part. IVA 00905811006
R.E.A. Roma n. 756453

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org