471,338 Members | 1,076 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,338 software developers and data experts.

Glade + Python = No GUI

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.

Thanks in advance

Sep 2 '07 #1
5 2277
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
Sep 2 '07 #2
On Sep 2, 7:29 pm, Wildemar Wildenburger
<lasses_w...@klapptsowieso.netwrote:
>
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

Nope, everything imports well, no errors. With import gtk added,
I get the same thing...

Sep 2 '07 #3
Kveldulv wrote:
When interrupted, I get

File "gui.py", line 11, in <module>
gtk.main()
Ah, I see now. Thats just telling you that *you* interrupted the
function/method/whateverthatis.
When GUI coded manually, all works.
Hence: Something in your (generated) code or XML file is corrupt or
missing. Perhaps some sort of show() call or attribute. I really only
have marginal experience with pygtk so I'm just stabbing at thin air.

sorry :(
/W
Sep 2 '07 #4
On Sep 2, 9:07 pm, Wildemar Wildenburger
<lasses_w...@klapptsowieso.netwrote:
Kveldulv wrote:
When interrupted, I get
File "gui.py", line 11, in <module>
gtk.main()

Ah, I see now. Thats just telling you that *you* interrupted the
function/method/whateverthatis.
When GUI coded manually, all works.

Hence: Something in your (generated) code or XML file is corrupt or
missing. Perhaps some sort of show() call or attribute. I really only
have marginal experience with pygtk so I'm just stabbing at thin air.

sorry :(
/W
I sorted it out and you're right. I didn't found out why this thing
didn't work since
it's c/pasted straight from the book I'm learning from but this did
the trick:

class TwoButtonsGUI:
def __init__(self):
xml = gtk.glade.XML("buttons.glade")
self.window = xml.get_widget("window1")
self.window.show()

etc

Thanks for help!

Sep 2 '07 #5
Note to myself and python noobs like me:
Don't forget to set Visible to yes on main window in Glade :)

Sep 2 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Hans Deragon | last post: by
1 post views Thread by Will Ware | last post: by
9 posts views Thread by P. Jouin | last post: by
5 posts views Thread by somesh | last post: by
6 posts views Thread by Doug | last post: by
reply views Thread by Terry Hancock | last post: by
4 posts views Thread by cucap | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.