我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用gi.repository.GObject.PARAM_READWRITE。
def _reflect_on_gproperty(cls, prop): gname = prop.name.replace('-', '_') type_sig = cls.PROP_SIGS.get(gname, 'v') access_map = { gobject.PARAM_READWRITE: 'readwrite' , gobject.PARAM_READABLE: 'read' , gobject.PARAM_WRITABLE: 'write' } access = 'read' if getattr(cls.__class__, gname, None): access = access_map.get(getattr(cls.__class__, gname).flags, 'read') reflection_data = ' <property name="%s" type="%s" access="%s">\n' % (gname, type_sig, access) for annotation in getattr(prop, '_dbus_annotations', [ ]): reflection_data += ' <annotation name="%s" value="true" />\n' % pair # reflection_data += ' <arg direction="in" type="%s" name="%s" />\n' % pair reflection_data += ' </property>\n' return reflection_data
def _reflect_on_dict(cls, props): reflection_data = '' for name, prop in props.items( ): value = prop type_sig = cls.PROP_SIGS.get(name, 'v') access_map = { gobject.PARAM_READWRITE: 'readwrite' , gobject.PARAM_READABLE: 'read' , gobject.PARAM_WRITABLE: 'write' } access = 'readwrite' reflection_data += ' <property name="%s" type="%s" access="%s">\n' % (name, type_sig, access) for annotation in getattr(prop, '_dbus_annotations', [ ]): reflection_data += ' <annotation name="%s" value="true" />\n' % pair # reflection_data += ' <arg direction="in" type="%s" name="%s" />\n' % pair reflection_data += ' </property>\n' return reflection_data