何时导入联合国

2024-04-28 23:13:46 发布

您现在位置:Python中文网/ 问答频道 /正文

使用ubuntu12.04和LibreOffice 3.5.7.2。在

我试图理解Libre Office中的Python脚本。我在网上读了不少书,看过并运行了一些例子。我注意到有些例子导入了uno,有些没有,它们都运行得很好,但是如果我注释掉import uno,脚本就停止工作了。在

有人能给我解释一下uno什么时候需要进口吗。在

谢谢,吉姆


Tags: import脚本libreoffice例子unoofficelibre
2条回答

尝试只导入uno。最多只能让你的程序慢2秒。在

import uno ##JUST DO It!

你看过什么例子?在

需要UNO上下文时需要UNO。这允许您在LO或OOo上连接。在

下面是一个小例子,当您需要使用UNO时。在

import uno

# get the uno component context from the PyUNO runtime
localContext = uno.getComponentContext()

# create the UnoUrlResolver
resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext )

ctx = resolver.resolve( "uno:pipe,name=addtemppipe;urp;StarOffice.ComponentContext" )

相关问题 更多 >