> 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.
How are you creating the property ?

the "correct" approach is the following:

class SomeClass(GObject.Object, App.Iface):
  p = GObject.Property(type=GObject.Type)
  def __init__(self, arg1, arg2, arg3, arg4):
    super().__init__()

    self.p = arg4

Note that you should subclass a concrete object type, just as Simon
McVittie told.

if can I ask, why are you trying to pass an interface as parameter to
class constructor ? Some interfaces requires you to install some
properties, for example Gtk.Orientable requires that you install
"orientation" property. I can't imagine a use for this.

Any way, the syntax for creating properties is described above.

If you want a example of a custom type implementing a interface you can
see this widget that I've wrote:
https://github.com/hotvic/Gtk-Widgets/blob/master/python/gtkmeter.py

_______________________________________________
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list

Reply via email to