[pygtk] Signal with a float argument

BJörn Lindqvist bjourne at gmail.com
Tue Jan 30 02:15:51 WST 2007


import gobject
import gtk

class Foobar(gtk.Widget):
    __gsignals__ = {
        'ring_ring' : (gobject.SIGNAL_ACTION | gobject.SIGNAL_RUN_LAST,
                       None, (str,)),
        'ring_loud' : (gobject.SIGNAL_ACTION | gobject.SIGNAL_RUN_LAST,
                       None, (float,))
        }
    def __init__(self):
        super(Foobar, self).__init__()

    def do_ring_ring(self, arg):
        print "RINGING!", arg

    def do_ring_loud(self, arg):
        print "RINGING", arg

gobject.type_register(Foobar)
gtk.binding_entry_add_signal(Foobar, gtk.keysyms.r, 0, 'ring_ring',
                             str, "Hello olle")
gtk.binding_entry_add_signal(Foobar, gtk.keysyms.m, 0, 'ring_loud',
                             float, 12.0)

f = Foobar()
gtk.bindings_activate(f, gtk.keysyms.r, 0)
gtk.bindings_activate(f, gtk.keysyms.m, 0)

When running the above code on Windows it produces the following output:

  RINGING! Hello olle
  RINGING 5.92878775009e-323

That is wrong, the second line should have been "RINGING 12.0". Is it
a bug in PyGTK or am I doing something wrong?

-- 
mvh Björn


More information about the pygtk mailing list