I submitted the following message a few days ago but got it stuck in the
moderators queue, so I bit the bullet, subscribed, and am re-posting.
Sorry.

On Sat, 2004-04-17 at 16:09, Travis D. Ray wrote:
> Begin forwarded message:
> 
> > From: Travis D. Ray <redacted>
> > Date: April 13, 2004 11:54:08 PM CDT
> > To: [EMAIL PROTECTED]
> > Subject: a couple of bugs(?) with pygtk-2.3.90
> >
> > Hi,
> >     I've installed pygtk-2.3.90 (as well as gtk+-2.4.0) to my own little 
> > development sandbox (/var/tmp/sandbox), and I've come across a couple 
> > of issues for which I'm soliciting comments before filing bug-reports.
> >
> > 1.  When creating a new signal using the __gsignals__ dictionary of 
> > tuples, the last tuple element *must* be a sequence.  I have need (I 
> > think) of creating signals that do not pass arguments when emitted.  I 
> > managed to hack gobjectmodule.c: create_signal to allow one to specify 
> > gtk.TYPE_NONE as well as a sequence, and it appears to have worked.
> >
> > Should I file a bug report? (or post a patch to the list?)
> >
> > This leads me to my second issue...
> >
> > 2.   It was not enough to set PYTHONPATH to 
> > '/var/tmp/sandbox/lib/python2.3/site-packages' when invoking a script 
> > that imports gobject.  The result was that gtk was loading from where 
> > I expected, but gobject was being loaded from outside my sandbox.  
> > Appending /var/tmp/sandbox/lib/python2.3/site-packages/gtk-2.0 solves 
> > the problem, but I wouldn't expect to have to do that.  (I have no 
> > idea where to start or even how to approach a fix for this one.)
> >
> > Should I file a bug report?
> >
> >
> > BTW, many thanks for all the hard work!
> >

I've also encountered anomolous behaviour when attempting to destroy an
instance subclassed from gobject.  I receive errors of the form:

GLib-GObject-CRITICAL **: file gobject.c: line 1579 (g_object_unref):
assertion `G_IS_OBJECT (object)' failed

Also, it *sometimes* signals a SEGV.  I'm not sure why it only occurs
*sometimes*.  I've verified that the above anomoly also occurs with
stock pygtk (not the version I've tweaked).  I'm attaching an example
(that is reproducible with the released version), so maybe someone can
say for sure it *is* a problem or I'm just ignorant.

Thanks again!


BTW:
test_signals-2.py works fine (but no user-defined signals).
test_signals-3.py is the one causing problems.


import gtk

class OneButtonWindow(gtk.Window):
    def __init__(self):
        gtk.Window.__init__(self)

        self.ok_button = gtk.Button(stock='gtk-ok')
        self.add(self.ok_button)
 
        self.show_all()


class TwoButtonWindow(gtk.Window):
    def __init__(self):
        gtk.Window.__init__(self)

        hbox = gtk.HBox()
        self.add(hbox)

        self.no_button = gtk.Button(stock='gtk-no')
        hbox.pack_start(self.no_button)

        self.yes_button = gtk.Button(stock='gtk-yes')
        hbox.pack_start(self.yes_button)

        self.show_all()


def quit(*args):
    gtk.main_quit()

def ok_clicked(b, w):
    def yes_clicked(b, w):
        w.destroy()
        quit()

    def no_clicked(b, w):
        w.destroy()

    tbw = TwoButtonWindow()
    tbw.yes_button.connect('clicked', yes_clicked, tbw)
    tbw.no_button.connect('clicked', no_clicked, tbw)
    tbw.connect('delete-event', quit)
    
obw = OneButtonWindow()
obw.ok_button.connect('clicked', ok_clicked, obw)
obw.connect('delete-event', quit)

gtk.main()   


     
import gtk, gobject

class OneButtonWindow(gtk.Window):
    __gsignals__ = { 'acknowledged': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)) }

    def __init__(self):
        #gtk.Window.__init__(self)
        gobject.GObject.__init__(self)

        self.ok_button = gtk.Button(stock='gtk-ok')
        self.ok_button.connect('clicked', self.acknowledged)
        self.add(self.ok_button)
 
        self.show_all()

    def acknowledged(self, *args):
        print "acknowledged:", args
        self.emit('acknowledged', "")

gobject.type_register(OneButtonWindow)


class TwoButtonWindow(gtk.Window):
    __gsignals__ = { 'affirmative': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)), 
                     'negative':    (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)) }
    def __init__(self):
        #gtk.Window.__init__(self)
        gobject.GObject.__init__(self)

        hbox = gtk.HBox()
        self.add(hbox)

        self.no_button = gtk.Button(stock='gtk-no')
        self.no_button.connect('clicked', self.negative)
        hbox.pack_start(self.no_button)

        self.yes_button = gtk.Button(stock='gtk-yes')
        self.yes_button.connect('clicked', self.affirmative)
        hbox.pack_start(self.yes_button)

        self.show_all()

    def affirmative(self, *args):
        print "affirmvative:", args
        self.emit('affirmative', "")

    def negative(self, *args):
        print "negative:", args
        self.emit('negative', "")

gobject.type_register(TwoButtonWindow)

def quit(*args):
    gtk.main_quit()

def ok_clicked(w0, n, w1):
    print w0, n, w1

    def yes_clicked(w0, n, w1):
        print w0, n, w1
        w0.destroy()
        w1.destroy()
        quit()

    def no_clicked(w0, n, w1):
        print w0, n, w1
        w0.destroy()

    tbw = TwoButtonWindow()
    tbw.connect('affirmative', yes_clicked, tbw)
    tbw.connect('negative', no_clicked, tbw)
    tbw.connect('delete-event', quit)
    
obw = OneButtonWindow()
obw.connect('acknowledged', ok_clicked, obw)
obw.connect('delete-event', quit)

gtk.main()   


     
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to