473,399 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 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 2372
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Hans Deragon | last post by:
Greetings. Total newbie to Glade here. I created an interface using glade-2 and I want to use it with my python program. Following is what I wrote (test prg): -------------------------...
1
by: Will Ware | last post by:
In July there was a thread about problems on Red Hat 9 with PyGTK not playing nice with Glade. I was tinkering with this a little bit tonight, starting with the code I found in this article:...
9
by: P. Jouin | last post by:
I work with Linux Mandrake10 and KDE. I have compiled and install : Python 2.3.4 pygtk-2.2.0 Glade2 2.6.0 My problem is : I want to know what can i do for having Python in the Language of...
5
by: somesh | last post by:
hello, I wrote a small tute for my brother to teach him python + glade, plz see, and suggest to make it more professional , In tute I discussed on Glade + Python for developing Applications too...
6
by: Doug | last post by:
Hi all, Can someone tell me why I do not get a connection between the events and the functions in the sample below. GUI window appears OK, just no connections seem to be made. I am new to this...
0
by: Terry Hancock | last post by:
I've run into something a little odd on my Debian-installed Python 2.3. I have deb packages "python2.3", "python-gtk2", and "python2.3-glade2" installed on this machine. Among other things,...
4
by: cucap | last post by:
Hello everyone, I'm new to this forum and a sort of beginner at Python. I've created a GUI in Python using Glade and GTK and I have two questions. I'm having trouble with comboboxes. Particularly...
0
by: zabeehkhan | last post by:
Hello everyone, I have created the Graphical structure of my software with Glade and now want a little help from you. I use Windowx XP and have installed everything correctly and the newest...
5
by: holmes86 | last post by:
hi,everyone. I am a python newbie.and I write a python program with glade,as following: import sys import gtk import gtk.glade class TLaitSignals: '''Define TLait singals handler'''
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.