KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17
System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64
User : nobody ( 99)
PHP Version : 5.2.17
Disable Function : NONE
Directory :  /usr/share/doc/pygtk2-2.10.1/examples/gobject/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/doc/pygtk2-2.10.1/examples/gobject/properties.py
import gobject

class MyObject(gobject.GObject):
    __gproperties__ = {
        'foo': (gobject.TYPE_STRING, 'foo property', 'the foo of the object',
                'bar', gobject.PARAM_READWRITE),
        'boolprop': (gobject.TYPE_BOOLEAN, 'bool prop', 'a test boolean prop',
                     0, gobject.PARAM_READABLE),
    }

    def __init__(self):
        self.__gobject_init__()
        self.foo = 'bar'
    def do_set_property(self, pspec, value):
        print '    do_set_property called for %s=%r' % (pspec.name, value)
        if pspec.name == 'foo':
            self.foo = value
        else:
            raise AttributeError, 'unknown property %s' % pspec.name
    def do_get_property(self, pspec):
        print '    do_get_property called for %s' % pspec.name
        if pspec.name == 'foo':
            return self.foo
        elif pspec.name == 'boolprop':
            return 1
        else:
            raise AttributeError, 'unknown property %s' % pspec.name
gobject.type_register(MyObject)

print "MyObject properties: ", gobject.list_properties(MyObject)
obj = MyObject()

val = obj.get_property('foo')
print "obj.get_property('foo') == ", val

obj.set_property('foo', 'spam')
print "obj.set_property('foo', 'spam')"

val = obj.get_property('foo')
print "obj.get_property('foo') == ", val

val = obj.get_property('boolprop')
print "obj.get_property('boolprop') == ", val

Anon7 - 2021