[pygtk] TreeModel from Dot Notation

A.T.Hofkamp a.t.hofkamp at tue.nl
Mon Aug 18 20:08:40 WST 2008

Patty Ackermann wrote:
> Hi,
> I am trying to make a treeview out of some data, namely produce. The data
> contains an arbitrary number of items, with each item representing a series
> a levels. For example,
> produce_list = [Fruit.Apple.Green, Fruit.Orange.Tangerine, Fruit.Banana,
> Vegetable.Tomato.Red.Ripe,...]
> The treemodel I want must look like this:
> Fruit
>    Apple
>       Green
>    Orange
>       Tangerine
>    Banana
> Vegetable
>    Tomato
>        Red
>            Ripe
> Does anyone have any clues as to how I could do this? I wish there was some
> way to interpret the '.' notation and get some sort of treeview out of it.
> Thanks a million in advance.

This is a general Python question instead of a pygtk question. You are better 
off asking for help at a more general Python list, for example the c.l.p. news 

In almost all groups, people usually don't respond well to being asked to 
solve some one else's problem for them. Therefore, I'd suggest you first try 
to solve the problem yourself. Read about the string functions and 
dictionaries in Python.

Good luck,

More information about the pygtk mailing list