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

Discussion in 'Python' started by Hans Deragon, Jul 5, 2003.

  1. Hans Deragon

    Hans Deragon Guest

    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
     
    Hans Deragon, Jul 5, 2003
    #1
    1. Advertising

  2. In article <>, 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
     
    David M. Cook, Jul 5, 2003
    #2
    1. Advertising

  3. Hans Deragon

    Hans Deragon Guest

    "David M. Cook" <> wrote in message news:<d2HNa.427458$>...
    > In article <>, 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
     
    Hans Deragon, Jul 6, 2003
    #3
  4. In article <>, 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
     
    David M. Cook, Jul 6, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave In Redmond

    Re: Update to Python 2.3 on Red Hat Linux 9

    Dave In Redmond, Aug 29, 2003, in forum: Python
    Replies:
    1
    Views:
    414
    Jay Bromley
    Aug 30, 2003
  2. Bengt Richter
    Replies:
    4
    Views:
    350
    Bengt Richter
    Sep 1, 2003
  3. Will Ware

    glade/pygtk trouble on Red Hat 9

    Will Ware, Feb 12, 2004, in forum: Python
    Replies:
    1
    Views:
    341
  4. Kai Strempel
    Replies:
    0
    Views:
    363
    Kai Strempel
    Jan 3, 2006
  5. Hueen Hueen

    openssl on Red Hat not installed

    Hueen Hueen, Dec 20, 2006, in forum: Ruby
    Replies:
    11
    Views:
    205
    Hueen
    Dec 20, 2006
Loading...

Share This Page