overrides: make them importable with current gtk4 master
[pygobject.git] / examples / properties.py
blob257e80a6c4ebad653a527eb7426d2ed67ef2f8fd
1 from gi.repository import GObject
4 class MyObject(GObject.GObject):
6 foo = GObject.Property(type=str, default='bar')
7 boolprop = GObject.Property(type=bool, default=False)
9 def __init__(self):
10 GObject.GObject.__init__(self)
12 @GObject.Property
13 def readonly(self):
14 return 'readonly'
17 GObject.type_register(MyObject)
19 print("MyObject properties: ", list(MyObject.props))
21 obj = MyObject()
23 print("obj.foo ==", obj.foo)
25 obj.foo = 'spam'
26 print("obj.foo = spam")
28 print("obj.foo == ", obj.foo)
30 print("obj.boolprop == ", obj.boolprop)
32 print(obj.readonly)
33 obj.readonly = 'does-not-work'