Evgeny Chukreev wrote: >Hello! [repost] > >I have tried to create private signal for my class. >Now it looks like: > >-- - - - -- - - - - - - - - - - - - - - - -- >import gtk, gobject > >class A (gtk.Window, gobject.GObject): > eek! If you just want a gtk.Window subclass, don't also subclass from gobject.GObject
> def __init__ (self): > gobject.GObject.__init__ (self) > gtk.Window.__init__ (self) > eek again. When creating a subclass that will have its own GType, don't chain to the parent constructor, or the GObject you create won't have the correct type. So only call gobject.GObject.__init__(self), or self.__gobject_init__() (which is equivalent). > >gobject.signal_new ("no_undo", A, > gobject.SIGNAL_RUN_FIRST, > gobject.TYPE_NONE, > ()) > You need to tell pygtk to derive the new GType for your class before adding signals, or you will end up adding them to the parent class. > >inst = A() > >print gobject.signal_list_names (inst) >print gobject.signal_list_names (gtk.Window) >- - - -- - - - - - - - - - - - - - - - - - - - >I got this as result: > >('no-undo', 'set-focus', 'frame-event', 'activate-focus', 'activate-default', >'move-focus', 'keys-changed') >('no-undo', 'set-focus', 'frame-event', 'activate-focus', 'activate-default', >'move-focus', 'keys-changed') > >Is there way to create 'no-undo' signal for the A class only (not for Window)? > > Try changing your code to look like the following: class A(gtk.Window): __gsignals__ = { 'no_undo': (gobject.SIGNAL_RUN_FIRST, None, ()) } def __init__(self): self.__gobject_init__() def do_no_undo(self): print "no_undo class closure called!" gobject.type_register(A) That should do what you want. James. -- Email: [EMAIL PROTECTED] | Linux.conf.au http://linux.conf.au/ WWW: http://www.daa.com.au/~james/ | Jan 22-25 Perth, Western Australia. _______________________________________________ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/