Presumably you've got some way in your data storage to associate your leaf
data items with their parent, if not then that is where you need to start.
Robin,
I believe that I do have the leaves properly associated with their twigs.
The item ID hierarchy is explicit for the root and the branches, but not for
the twigs:
rootID
>
+- natID
>
+- ecoID
>
+- socID
To add them to the tree you can simply locate all the leaf items for a
particular twig when you add that twig, and then add the leaves to the
twig the same way.
The twigs are appended to the proper branches with, for example,
for item in self.appData.polNat:
ngc = self.polTree.AppendItem(self.natID, item[0])
The leaves are now correctly associated with their twigs (verified by
adding 'print' statements to print twigs and leaves), thanks to Tom's help:
policy = self.polTree.GetItemText(ngc)
subpolicies = [sp[0] for sp in self.appData.subPols if sp[1]==policy]
But, the variable, 'policy,' is not the itemID for the twig, but the
string identifying each twig. So, when I try
spol = self.polTree.AppendItem(???, subpolicies)
I don't know what to put for the itemID field where the question marks are.
In other words, your data storage should have some way of representing the
hierarchy of the items, and your treectrl simply needs to reflect that. Start first with the data model, and then worry about the view. If the
model is done right then the view should be fairly simple.
The twigs and leaves (policies and subpolicies) are held in two tables in
the SQLite database.
Rich
···
On Fri, 15 Dec 2006, Robin Dunn wrote:
--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc.(TM) | Accelerator
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863