File: properties.py

package info (click to toggle)
pygobject 2.14.2-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,732 kB
  • ctags: 1,489
  • sloc: ansic: 11,090; sh: 9,052; xml: 3,391; python: 2,565; makefile: 351
file content (31 lines) | stat: -rw-r--r-- 592 bytes parent folder | download | duplicates (5)
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'