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

lauren at protopc.com lauren at protopc.com
Thu Jul 17 03:38:03 CEST 2008


Thanks again - I so appreciate your direction!

Okay so i have a list of lists just as you describe below...I hate to make
myself look really stupid...but I don't see how this converts to a tree
structure...I was looking at this earlier and I guess what's confusing me
are the duplicates...do I need to convert the list below into a data
structure of tuples? Can this be plugged straight into a tree control?

Now my question is:

How do I get from here:
 [('north america', 'United States', 'California'),
 ('north america', 'United States, 'Texas'),
 ('north america', 'United States, 'Washington'),
 ('north america', 'Canada', 'Ontario'),
 ('Asia', 'Japan', None),

To Here:
geo=[("north america", [
        ("united states",[
            ("california", []),
            ("oregon", []),
             ("arizona", [])]),
        ("canada", [
            ("Ontario", [])])]),
     ("asia", [
        ("japan", [])])


> From looking at your other email, my guess is that you want to start
> with SQL looking something like this:
> select continent, country, state from world_globe
> with the intention of getting back data that looks like:
> [('America', 'United States', 'California'),
> ('America', 'United States, 'Texas'),
> ('America', 'United States, 'Washington'),
> ('America', 'Canada', 'Ontario'),
> ('Asia', 'Japan', None),
> # etc
> ]
> It would be fairly straightforward to take data looking something like
> that and produce a tree.
> --
> John.

More information about the Tutor mailing list