[pygtk] Multilevel ListStore

Walter Leibbrandt walter at translate.org.za
Tue Jul 8 15:04:03 WST 2008


Hi,

Run pygtk-demo. The only real difference to a normal ListStore is =

specifying the parent gtk.TreeIter when you add rows:

<code>
model =3D gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
parentIter =3D model.append(None)
model.set(parentIter,
    0, "Parent (1st col)",
    1, "Parent (2nd col)"
)

childIter =3D model.append(parentIter)
model.set(childIter,
    0, "Child (1st col)",
    1, "Child (2nd col)"
)
childIter2 =3D model.append(parentIter)
model.set(childIter2,
    0, "Child2 (1st col)",
    1, "Child2 (2nd col)"
)
</code>

This will add a top-level row (referenced by parentIter) and two rows =

under it (referenced by childIter and childIter2). Then you can do =

"level2iter =3D model.append(childIter)" to add a row with the first child =

row (childIter) as its parent.

The PyGtk tutorial also covers this in section 14.2.4.2 ("Adding Rows to =

a TreeStore") and that's about as hard as it gets.

Hope this helps.

Regards,
Walter

P.S. The code above was written on-the-go, so it might not be 100% correct.

Shadi Azoum wrote:
> Thanks for the tip, Paul. Any code example on using TreeStore? The offici=
al pygtk tutorials offer little support.
>
>
> ----- Original Message -----
> From: Paul Pogonyshev <pogonyshev at gmx.net>
> Date: Sunday, July 6, 2008 3:51 am
> Subject: Re: [pygtk] Multilevel ListStore
> To: pygtk at daa.com.au
> Cc: Shadi Azoum <ssa03d at fsu.edu>
>
>   =

>> Shadi Azoum wrote:
>>     =

>>> Any help would be greatly appreciated.
>>>       =

>> Use gtk.TreeStore instead.
>>
>> Paul
>>
>>     =

> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
>   =

-------------- next part --------------
A non-text attachment was scrubbed...
Name: walter.vcf
Type: text/x-vcard
Size: 263 bytes
Desc: not available
Url : http://www.daa.com.au/pipermail/pygtk/attachments/20080708/fe20dd51/w=
alter.vcf


More information about the pygtk mailing list