GNOME Bugzilla – Bug 784991
Support Child Properties
Last modified: 2018-01-10 20:59:47 UTC
Bug 338098 added support for defining object properties using GObject.Property. In pygtk I was creating child properties using a dictionary, for example: __gchild_properties__ = { 'weight': (GObject.TYPE_FLOAT, 'item weight', 'item weight', 0, # min 1, # max .2, # default GObject.ParamFlags.READWRITE ), } and then: for index, (name, pspec) in enumerate(six.iteritems(DockPaned.__gchild_properties__)): pspec = list(pspec) pspec.insert(0, name) Gtk.ContainerClass.install_child_property(DockPaned, index + 1, tuple(pspec)) Unfortunately with PyGObject this gives a TypeError: argument pspec: Expected GObject.ParamSpec, but got tuple There needs to be a way to create child properties through install_child_property. What if we defined these properties using a new GObject.ChildProperty solution similar to what was added for other normal properties?
I figured out that I can change my code to make use of GObject.param_spec_float to create a pspec, for example: Gtk.ContainerClass.install_child_property(DockPaned, 2, GObject.param_spec_float('weight', 'item weight', 'item weight', 0, 1, .2, GObject.ParamFlags.READWRITE)) TypeError: argument pspec: Expected GObject.ParamSpec, but got gobject.GParamSpec Could we fix this by calling the override decorator from the overrides/__init__ module to force the gobject.GParamSpec type to be a GObject.ParamSpec?
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pygobject/issues/138.