Re: Implementing GObject interfaces in Python
- From: "Victor A. Santos" <victoraur santos gmail com>
- To: "W. Michael Petullo" <mike flyn org>
- Cc: gtk-devel-list gnome org
- Subject: Re: Implementing GObject interfaces in Python
- Date: Wed, 25 Jun 2014 13:43:34 -0300
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]