libreoffice python access属性对象



给定通过这种方式获得的变量properties的属性

view_settings = current_controller.ViewSettings
property_set=view_settings.getPropertySetInfo()
properties=property_set.getProperties()

如何访问这些值

例如:

(com.sun.star.beans.Property){ Name = (string)"ZoomValue", Handle = (long)0x1b, Type = (type)short, Attributes = (short)0x0 }

这些失败:

properties.ZoomValue
properties.getattr('ZoomValue')
properties['ZoomValue']

你好像有点迷路了。😊这足以获取值。

view_settings = current_controller.ViewSettings
view_settings.ZoomValue

getPropertySetInfo()告诉关于属性的信息,而不是给予对属性值的访问权。例如,您可以像这样确定属性类型:

propinfo = property_set.getPropertyByName('ZoomValue')
propinfo.Type

结果:

<Type instance short (<Enum instance com.sun.star.uno.TypeClass ('SHORT')>)>

最新更新