Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Glade + Python = No GUI

Reply
Thread Tools

Glade + Python = No GUI

 
 
Kveldulv
Guest
Posts: n/a
 
      09-02-2007
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

 
Reply With Quote
 
 
 
 
Wildemar Wildenburger
Guest
Posts: n/a
 
      09-02-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
 
Reply With Quote
 
 
 
 
Kveldulv
Guest
Posts: n/a
 
      09-02-2007
On Sep 2, 7:29 pm, Wildemar Wildenburger
<lasses_w...@klapptsowieso.net> wrote:

>
> 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...

 
Reply With Quote
 
Wildemar Wildenburger
Guest
Posts: n/a
 
      09-02-2007
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
 
Reply With Quote
 
Kveldulv
Guest
Posts: n/a
 
      09-02-2007
On Sep 2, 9:07 pm, Wildemar Wildenburger
<lasses_w...@klapptsowieso.net> wrote:
> 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!

 
Reply With Quote
 
Kveldulv
Guest
Posts: n/a
 
      09-02-2007
Note to myself and python noobs like me:
Don't forget to set Visible to yes on main window in Glade



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
My 2nd Glade GUI with Python AppelonD Python 0 06-12-2010 08:44 AM
(debian,eclipse) GUI created with glade doesn't appear lolveley Ruby 0 04-24-2009 08:33 PM
Please help a windows user get started with python/glade and an IDE. Al Dykes Python 2 10-15-2004 11:07 PM
Python and Glade-2 P. Jouin Python 9 08-03-2004 01:48 PM
Red Hat 9, Python and Glade - a mixure not working? Hans Deragon Python 3 07-06-2003 06:13 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57