Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I'm on the same journey you are trying to learn Glade on python and I ran into the same issues you did. I'm still not at full understanding by any means, but perhaps my discoveries can help you.

First, every tutorial, including those at the glade home page seem to be out of date. They all say to "import gtk", but this seems to be old even though it is packaged with F16. If you use this gtk then you will get the error from gtkbuilder. Instead I found that the following code works and doesn't cause an error:

import gi
gi.require_version("Gtk", "3.0")
# from gi.repository import Gtk,GdkPixbuf,GObject,Pango,Gdk
from gi.repository import Gtk

# import gtk -- this doesn't work

class CommanderApp(object):       
    def __init__(self):
        self.builder = Gtk.Builder()

        self.window = self.builder.get_object("window")
        self.about = self.builder.get_object("about_dialog");
        self.choose = self.builder.get_object("chooser_dialog");
        self.bookStore = self.builder.get_object("bookstore");
        self.bookView = self.builder.get_object("bookview");


    def on_window_destroy(self, widget, data=None):

    def on_open_menu_item_activate(self, widget, data=None):

        self.curDir = self.choose.get_files();
        for b, v in listBooks([x.get_path() for x in self.curDir]).items():
            self.bookStore.append((v[TITLE], v[CREATOR]))

    def on_quit_menu_item_activate(self, widget, data=None):

    def on_delete_menu_item_activate(self, widget, data=None):

    def on_about_menu_item_activate(self, widget, data=None):

Obviously, this is a fragment from my program, but hopefully it give you an idea. I've been using Glade3, eclipse PyDev and python with success. My UI has a simple GtkTreeView view with a GtkListStore.

One other issue though, in order to get columns in a tree view I had to add GtkTreeColumn items with GtkCellRendererText children. However, I could not find these two elements in the glade UI builder. Furthermore when I selected my GtkTreeView element and right-click->Edit..., glade crashes. I eventually edited the glade file by hand to add the elements. After that when I open the file in Glade then I see these elements in the widget window and the preview (the edit sequence still crashes though).

Anyway that is where I'm at. I have my UI displaying and responding, so I'm calling it a success :-)