Hi guys.

So, I'm trying to read data from a database and displaying in a GtkTreeview. I used glade to design the GUI
when i click on the button (view movies) the list of movies should display as a list.

def on_btnmovies_clicked(self,widget,data=None):
        store=self.builder.get_object('listmovies')
        connect=sqlite.connect('movies.db')
        db=connect.cursor()
        db.execute("SELECT * FROM movie")
        for title in db.fetchall():
            store.append[(title[1])] #Get the movie Titles only and add to GtkListStore
        store=self.builder.get_object('listmovies')

I've been looking around trying to find how to actullay display the list. I've been using Click Here to read more about GtkTreeviews

In Glade I already set the GtkTree_model for GtKTreeview to GtkListStore, called listmovies, but when I run the application, the list does not show up, not even the GtkTreeview container.

I dont get any errors.

I'm unable to find the reason why the list does not show up, anybody have suggestions?

I don't know how glade works, but I recently hand coded a GtkListStore, and I remember that the method treeview.add_column() must be called on each column that you want to see to correctly initialize the treeview. Can you check this in your code ?

edit: sorry, it's append_column()

ok, I see GtkTreeView uses GtkTreeViewColumn to organise the data into vertical columns.

To activate GtkTreeViewColumn, I had to right click (in glade) on GtkTreeView, edit, select hierarchy tab, add a new column, give it a label, done.

I Hard coded some entires, but the text is not visible but the list does expand, seems like i'm missing something small.

edit: The only thing missing is the cell renderer, cant seem to find it it glade

Ok, I found it.

After adding a new column in GtkTreeView, right click on that column and different cell renderers will appear, I chose Text, and in the text field, choose whatever list you want from the drop down box.

My text now appears.

edit: I found the solution Here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.