[Tutor] Tree Ctrl Data Structure - Help, please!

Lauren Snyder lsnyder at cheyenneme.com
Tue Jul 15 20:52:43 CEST 2008


Hello!

 

ACK!!! I am attempting to "AUTO" populate a tree control....

 

Right now I am just focusing on dynamically creating the data structure
(a list of lists) that will later be used to populate the tree control. 

This is where I am stuck! 

 

Based on some research I've done,  I think I want my data structure to
be a series of lists within lists:

 

[ "node1", "node1a", "node1b", ["node1c", "node2", "node2a", "node2b",],
["node1d", ["node2c", "node3", "node3a"], "node2d"], "node1e"]]

 

-------------------------------------------------------------

The list above represents this tree structure:

 

Node1

 

Node1a

 

Node1b

 

Node1c

            Node2

            Node2a

            Node2b

 

Node1d

            Node2c

                        Node3

                        Node3a

            Node2d

 

Node1e

 

-------------------------------------------------------------

All of my data will be variable and I collect all the node information
via SQL queries. 

But now I have a series of lists:

 

["node1", "node1a", "node1b", "node1c", "node1d", "node1e"]

["node2", "node2a", "node2b", "node2c", "node2d"]

["node3", "node3a"]

 

If I execute my sql queries in a series of nested  'FOR' statements I
get the hierarchy for each node traversal (as shown below) - but not in
tree format. For example "1c" has many branches - so it is returned 3
times. 

 

Node1

Node1a

Node1b

 

Node1c

Node2

 

Node1c

Node2a

 

Node1c

Node2b

 

Node1d

Node2c

Node3

 

Node1d

Node2c

Node3a

 

Node1d

Node2d

 

************************************************************************
******

 

So - my questions:

 

Is there an existing method/class/library that already exists in python
to help me create the data structure I need for my tree structure?

If not, can someone give me some pointers on how to think about this
clearly??  I'm obviously missing some steps!! :-(

 

As an aside, I'm using wxpython for my GUI

Thanks!

Lauren

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080715/e73e4b89/attachment.htm>


More information about the Tutor mailing list