472,960 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,960 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 2349
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.