how to use gtk3 treestore in pygobject

1. Step:
create a treestoremodel
model=Gtk.TreeStore(str,str) (or use Gtk.Builder for this)

2. Step:
add an entry in the highest level and take its iterator. This can be done with
it=model.insert_with_values(None, -1, [0,1], [“hello”, “world”])
None: parent (None is the highest level)
-1: the last position=appending
[0, 1]: the columns
[“hello”,”world”]: fills the selected columns with values
it: the iterator, it becomes important for the next step

3. Step:
now we have an iterator. In the first call of insert_with_values we used None.
This is replaced by the iterator. And voila a child object

model.insert_with_values(iter, -1,[0,1],[“hello”,”child1″])
model.insert_with_values(iter, -1,[0,1],[“hello”,”child2″])

The last thing to do is to add the treestore to a treeview and add some Renderers for the columns,
but for that there is already a tutorial:



Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s