Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Red Hat 9, Python and Glade - a mixure not working?

Reply
Thread Tools

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

 
 
Hans Deragon
Guest
Posts: n/a
 
      07-05-2003
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
 
Reply With Quote
 
 
 
 
David M. Cook
Guest
Posts: n/a
 
      07-05-2003
In article <(E-Mail Removed) >, 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
 
Reply With Quote
 
 
 
 
Hans Deragon
Guest
Posts: n/a
 
      07-06-2003
"David M. Cook" <(E-Mail Removed)> wrote in message news:<d2HNa.427458$(E-Mail Removed) >...
> In article <(E-Mail Removed) >, 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
 
Reply With Quote
 
David M. Cook
Guest
Posts: n/a
 
      07-06-2003
In article <(E-Mail Removed)> , 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
 
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
Red Hat Enterprise Edition and Python 2.4 sources Kai Strempel Python 0 01-03-2006 01:50 PM
glade/pygtk trouble on Red Hat 9 Will Ware Python 1 02-12-2004 10:33 AM
Red Hat Defines end of Red Hat Linux steve NZ Computing 14 11-06-2003 06:19 AM
Re: Update to Python 2.3 on Red Hat Linux 9 Bengt Richter Python 4 09-01-2003 05:30 PM
Re: Update to Python 2.3 on Red Hat Linux 9 Dave In Redmond Python 1 08-30-2003 03:13 AM



Advertisments