468,115 Members | 2,103 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,115 developers. It's quick & easy.

Red Hat 9, Python and Glade - a mixure not working?

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):

-------------------------
#!/usr/bin/python

import gtk
import gtk.glade
import sys

def on_button4_clicked(source=None, event=None):
sys.exit();

gtk.glade.XML('project3.glade')
xml.autoconnect({
'on_button4_clicked': on_button4_clicked
})

gtk.main()
-------------------------

Now when I am running it, I get the following error:

-------------------------
(run2.py:11714): GLib-GObject-CRITICAL **: file gobject.c: line 1002
(g_object_get): assertion `G_IS_OBJECT (object)' failed

(run2.py:11714): GLib-GObject-CRITICAL **: file gobject.c: line 1002
(g_object_get): assertion `G_IS_OBJECT (object)' failed
Erreur de segmentation
-------------------------

I am running redhat 9 with the lastest updates and glade-2. Anybody
has a clue how to get it running? Is there a python program that
comes in one of RH 9 packages that makes use of glade? I could use it
as an example.
Regards,
Hans Deragon
Jul 18 '05 #1
3 4094
In article <c7**************************@posting.google.com >, Hans Deragon
wrote:
def on_button4_clicked(source=None, event=None):
You should exit the mainloop here:

gtk.main_quit()
sys.exit();

gtk.glade.XML('project3.glade')
Should be

xml = gtk.glade.XML('project3.glade')
xml.autoconnect({
'on_button4_clicked': on_button4_clicked
})


Or you can just use

xml.signal_autoconnect(locals())

See glade_demo.py in the /usr/share/doc/pygtk2-1.99.14/examples/glade/.

For more info on pygtk see

http://www.async.com.br/faq/pygtk/index.py?req=index
http://www.moeraki.com/pygtkreference/pygtk2reference/

Dave Cook
Jul 18 '05 #2
"David M. Cook" <da******@nowhere.net> wrote in message news:<d2********************@news2.central.cox.net >...
In article <c7**************************@posting.google.com >, Hans Deragon
wrote:


[...deleted lines...]
gtk.glade.XML('project3.glade')


Should be

xml = gtk.glade.XML('project3.glade')


Ok, here I am embarrassed... forgetting to assign xml... ;)
xml.autoconnect({
'on_button4_clicked': on_button4_clicked
})


Or you can just use

xml.signal_autoconnect(locals())

See glade_demo.py in the /usr/share/doc/pygtk2-1.99.14/examples/glade/.


Thanks for the tips. But the problem still persist. Now I run the
following:

------------------
[root@world project3]#
/usr/share/doc/pygtk2-1.99.14/examples/glade/glade-demo.py
project3.glade

(glade-demo.py:3405): GLib-GObject-CRITICAL **: file gobject.c: line
1002 (g_object_get): assertion `G_IS_OBJECT (object)' failed

(glade-demo.py:3405): GLib-GObject-CRITICAL **: file gobject.c: line
1002 (g_object_get): assertion `G_IS_OBJECT (object)' failed
Segmentation fault
------------------

So the problem is not my code. I must assume that the glade module
for gnome is not adapted for taking in Glade 2 xml?

Then I tried with a Glade 1 xml:

-----------------
[root@world project2]#
/usr/share/doc/pygtk2-1.99.14/examples/glade/glade-demo.p
y project2.glade

(glade-demo.py:3541): libglade-WARNING **: Expected <glade-interface>.
Got <GTK
-Interface>.

(glade-demo.py:3541): libglade-WARNING **: did not finish in
PARSER_FINISH state
Traceback (most recent call last):
File "/usr/share/doc/pygtk2-1.99.14/examples/glade/glade-demo.py",
line 12, in
?
xml = gtk.glade.XML(fname)
RuntimeError: could not create GladeXML object
-----------------

Different errors, same results. Nothing works. However the
test.glade xml file provided as an example works fine. I believe that
there is some widget in my glade2 xml file that is simply not
supported by python. I will investigate further the issue later.

Thanks,
Hans Deragon
Jul 18 '05 #3
In article <c7*************************@posting.google.com> , Hans Deragon wrote:

Thanks for the tips. But the problem still persist. Now I run the
following:
Do you have gnome widgets in your xml file? You'll need to import gnome.ui
and do a gnome.init().

See the pygtk FAQ:

http://www.async.com.br/faq/pygtk/index.py?req=all

You might also try putting the line

import pygtk; pygtk.require('2.0')

at the top of your file. Also try running with python -v so you can see
what modules are being loaded.
So the problem is not my code. I must assume that the glade module
for gnome is not adapted for taking in Glade 2 xml?
In fact, libglade2 *only* works with glade 2 files. glade 1 files have to
be converted first.
Different errors, same results. Nothing works. However the
test.glade xml file provided as an example works fine. I believe that
there is some widget in my glade2 xml file that is simply not
supported by python. I will investigate further the issue later.


I've never encountered this problem with my own glade 2 files. However, I
don't have a "pristine" RH 9 installation to play with right now.

I suggest taking this problem to the pygtk mailing list. If it's not
quickly fixable then it needs to be fixed somewhere up the line.

Dave Cook
Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

37 posts views Thread by Ubaidullah Nubar | last post: by
59 posts views Thread by Hugh Macdonald | last post: by
5 posts views Thread by somesh | last post: by
7 posts views Thread by Madhusudan Singh | last post: by
reply views Thread by Doug | last post: by
6 posts views Thread by Doug | last post: by
5 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.