# Revision history [back]

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.choose = self.builder.get_object("chooser_dialog");
self.bookStore = self.builder.get_object("bookstore");
self.bookView = self.builder.get_object("bookview");

self.builder.connect_signals(self)
self.window.show()
Gtk.main()

def on_window_destroy(self, widget, data=None):
Gtk.main_quit()

self.choose.run()
self.choose.hide()

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]))
self.bookView.show()

Gtk.main_quit()