So you have some function, say Gtk.Builder.get_object()
, which returns some widget. In our case a Gtk.Window()
.
I have a subclass of Gtk.Window()
which adds some signal handlers.
class Window(Gtk.Window):
Is it possible to use the widget returned by Gtk.Builder.get_object()
to construct Window()
? I think it should be using __new__()
or something, but I can't figure it out.
__class__
attribute of theGtk.Window
instance you're getting? – Livraisonwindow.__class__ = cls
in__new__()
. I seem to be able to call methods from the subclass doing this, but__init__
still isn't run. According to my interpretation of the docs it should, so IDK. – Girardi__init__
if you're returning the modified instance from__new__
. I'm going to write the suggestion up as an answer, but feel free not to accept it until we can figure out what's going wrong. – Livraison