property#
Deprecated since version PyGObject-3.16.0: GObject.property is deprecated; use GObject.Property instead
- class property(getter=None, setter=None, type=None, default=None, nick='', blurb='', flags=3, minimum=None, maximum=None)#
Creates a new Property which when used in conjunction with GObject subclass will create a Python property accessor for the GObject ParamSpec.
- param callable getter:
getter to get the value of the property
- param callable setter:
setter to set the value of the property
- param type type:
type of property
- param default:
default value, must match the property type.
- param str nick:
short description
- param str blurb:
long description
- param GObject.ParamFlags flags:
parameter flags
- keyword minimum:
minimum allowed value (int, float, long only)
- keyword maximum:
maximum allowed value (int, float, long only)
class MyObject(GObject.Object):
prop = GObject.Property(type=str)
obj = MyObject()
obj.prop = 'value'
obj.prop # now is 'value'
The API is similar to the builtin property()
:
class AnotherObject(GObject.Object):
value = 0
@GObject.Property
def prop(self):
'Read only property.'
return 1
@GObject.Property(type=int)
def propInt(self):
'Read-write integer property.'
return self.value
@propInt.setter
def propInt(self, value):
self.value = value