/usr/share/doc/python-gobject-2/examples/properties.py is in python-gobject-2 2.28.6-13.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import gobject
class MyObject(gobject.GObject):
foo = gobject.property(type=str, default='bar')
boolprop = gobject.property(type=bool, default=False)
def __init__(self):
gobject.GObject.__init__(self)
@gobject.property
def readonly(self):
return 'readonly'
gobject.type_register(MyObject)
print "MyObject properties: ", list(MyObject.props)
obj = MyObject()
print "obj.foo ==", obj.foo
obj.foo = 'spam'
print "obj.foo = spam"
print "obj.foo == ", obj.foo
print "obj.boolprop == ", obj.boolprop
print obj.readonly
obj.readonly = 'does-not-work'
|