On Tue, Sep 6, 2011 at 13:57, Martin Voigt <[email protected]> wrote:
> I just found out that subclassing *does* work the old way, except for

That's the intention.

> classes that need arguments in their constructors, which Clutter.Box
> does (layout_manager). It seems one cannot reuse constructors from

I would have thought that it would still work to the same extent that
it worked before.

I myself don't do that and instead I treat C constructors as a
convenience for C programmers because if you use them instead of
GObject.__init__, the subclasses will have the same GType as their
parents and things like signals and properties will break.

> superclasses (without tangling with meta classes), so my current
> workaround is to mimic the superclass's behaviour in my own
> constructor, which is instance bound (__init__), not class bound like
> Box.new():
>
> class MyBox(clutter.Box):
>
>    def __init__(self, layout):
>        super(Map, self).__init__()
>        self.set_layout_manager(layout)
>
> Hm, maybe a better approach is available...

I would do instead:

class MyBox(clutter.Box):

   def __init__(self, **kwargs):
       GObject.__init__(kwargs)

Or just don't override __init__ at all if you don't need it.

Regards,

Tomeu

> bw,
> Martin
>
>
> On 6 September 2011 13:16, Martin Voigt <[email protected]> wrote:
>> Hey *,
>>
>> I'm using clutter from git (head), compiled with
>> --enable-introspection. Everything works fine in python, except that
>> I'm unable to subclass anything. With the old pyclutter this was quite
>> easy, but now I'm at a dead end. Since live.gnome.org is down for days
>> I cannot look up the documentation for gir and python, and every
>> google search I do seem to lead to live.gnome.org ;(
>>
>> Could anyone provide me with a simple example of, say, subclassing 
>> Clutter.Box?
>>
>> Thanks in advance,
>> Martin
>>
> _______________________________________________
> clutter-app-devel-list mailing list
> [email protected]
> http://lists.clutter-project.org/listinfo/clutter-app-devel-list
>
_______________________________________________
clutter-app-devel-list mailing list
[email protected]
http://lists.clutter-project.org/listinfo/clutter-app-devel-list

Reply via email to