tests: add a test for test_glist_gtype_container_in()
[pygobject.git] / examples / properties.py
blob4c8a20c0c442bafa73acc4f997c3aecad1084ded
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'
16 GObject.type_register(MyObject)
18 print("MyObject properties: ", list(MyObject.props))
20 obj = MyObject()
22 print("obj.foo ==", obj.foo)
24 obj.foo = 'spam'
25 print("obj.foo = spam")
27 print("obj.foo == ", obj.foo)
29 print("obj.boolprop == ", obj.boolprop)
31 print(obj.readonly)
32 obj.readonly = 'does-not-work'