Glade + Python = No GUI

Wildemar Wildenburger lasses_weil at klapptsowieso.net
Sun Sep 2 13:29:01 EDT 2007


Kveldulv wrote:
> I made simple GUI in Glade 3 (Ubuntu 7.04) consisting of only 2
> buttons. When I run
> 2buttonsgui.py, no GUI pops out
> 
> #!/usr/bin/env python
> import pygtk
> import gtk.glade
> 
> class TwoButtonsGUI:
>     def __init__(self):
>         self.window = gtk.glade.XML("/home/myusername/Desktop/
> 2buttons.glade", "window1")
> 
> if __name__ == '__main__':
>     TwoButtonsGUI()
>     gtk.main()
> 
> When interrupted, I get
> 
> File "gui.py", line 11, in <module>
>     gtk.main()
> 
> When GUI coded manually, all works.
> 
Shouldnt there be more to that error message of yours? I would expect 
something like "NameError: name 'gtk' is not defined"?

Because as it seems you haven't impored gtk (only gtk.glade). So adding 
"import gtk" at the beginning should help.

I may be wrong; I recall some weird importing requirements for pygtk, so 
I'm not sure if I'm to uninformed to see the actual problem.

/W



More information about the Python-list mailing list