M.Brbr
M.Brbr

Reputation: 83

How to create a Treeview with Glade and Gtk?

I am trying to build an interface with Glade and Gtk.

In Glade : I created a liststore labeled liststore. I added no column to that liststore. I then created a treeview labeled treeview and I chose liststore as a model for that treeview.

This is my code :

class CellRenderePartitions(Gtk.Box):
    self.liststore = builder.get_object('liststore')
    self.treeview = builder.get_object('treeview')
    self.treeview.model = self.liststore

    media = Gtk.CellRendererText()
    col = Gtk.treeViewColumn("Media",media,text=1)
    col.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
    col.set_expand(True)

    self.liststore.append(None)

I get this error :

Gtk_CRITICAL **: gtk_list_store_get_vlue: assertion column < priv->n_columns' failed

I know that the last line of my code is causing this trouble but I do not understand why, can anyone help ?

Upvotes: 2

Views: 1535

Answers (1)

theGtknerd
theGtknerd

Reputation: 3745

Your answer is in your own question. You don't have a column in your liststore, but you append some data to it. And yes, appending a None will be considered as a value, so you need a column to store that in.

Upvotes: 1

Related Questions