Simple question about loading a .glade UI file

Anthony Papillion papillion at gmail.com
Tue Jun 21 14:44:33 EDT 2011


Hi Everyone,

So I'm tackling designing a non-CLI program using Glade. I went through some
tutorials and it seems like I'm doing things right but I'm my UI won't load.
Python keeps griping about "could not create glade XML object".

I have a .glade file called MainWindow.glade and my main window is called
(predictably) winMain. Here is the code I'm using to load it:

#!/usr/bin/env python
import sys
try:
    import pygtk
    pygtk.require("2.0")
except:
    pass

try:
    import gtk
    import gtk.glade
except:
    print "GTK could not be loaded."
    sys.exit(1)

class GMB:

    def __init__(self):
self.gladefile = "MainWindow.glade"
 self.wTree = gtk.glade.XML(self.gladefile)
self.wTree.signal_autoconnect(self)
 self.window = self.wTree.get_widget("winMain")
if(self.window):
    self.window.connect("destroy", gtk.main_quit)

    def on_winMain_delete(self, widget, dummy):
gtk.main_quit()

if __name__ == "__main__":
    myGui = GMB()
    gtk.main()

Is there any reason why I'd be getting this error from the code above? Both
the UI file and the source code file are in the same directory.

Thanks!
Anthony
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110621/cd7fdc99/attachment.html>


More information about the Python-list mailing list