Implementing GObject interfaces in Python



Is it possible when using GObject introspection to implement a GObject
interface in Python?

I have written a GObject interface (in C) called I, along with the
following Python code:

        class MyClass (MyPkg.Iface):
                def __init__(self):
                        super(MyClass, self).__init__ ()

When I run this code, python terminates and prints:

        TypeError: Error when calling the metaclass bases
            argument must be a GObject subclass

Everything works fine if I replace the use of MyClass with an
implementation written in C.

Related to this, I am having trouble with g_param_spec_object(). I
would like to pass an interface as the fourth parameter to this
procedure (e.g., FOO_TYPE_SOME_INTERFACE). However, when I do so, Python
code that tries to set the corresponding property terminates and prints:

        Warning: g_object_new_valist:
        object class 'ClassX' has no property named 'p'

where p is the property that should be an interface.

Is it possible to specify an interface using g_param_spec_object(),
or must one use a real class?

Both of these issues seem to indicate that a GObject library should
implement primitive parent classes for its types instead of merely
providing interfaces for applications to implement. Is this the case?

Thank you,

-- 
Mike

:wq


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]