Branch and push for 2.0
[profile/ivi/pygobject2.git] / examples / properties.py
1 import gobject
2
3 class MyObject(gobject.GObject):
4
5     foo = gobject.property(type=str, default='bar')
6     boolprop = gobject.property(type=bool, default=False)
7
8     def __init__(self):
9         gobject.GObject.__init__(self)
10
11     @gobject.property
12     def readonly(self):
13         return 'readonly'
14
15 gobject.type_register(MyObject)
16
17 print "MyObject properties: ", list(MyObject.props)
18
19 obj = MyObject()
20
21 print "obj.foo ==", obj.foo
22
23 obj.foo = 'spam'
24 print "obj.foo = spam"
25
26 print "obj.foo == ", obj.foo
27
28 print "obj.boolprop == ", obj.boolprop
29
30 print obj.readonly
31 obj.readonly = 'does-not-work'