何时导入uno [英] When to import uno

查看:127
本文介绍了何时导入uno的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Ubuntu 12.04和LibreOffice 3.5.7.2.

Using Ubuntu 12.04 and LibreOffice 3.5.7.2.

我正在尝试了解Libre Office中的Python脚本.我已经在网络上阅读了很多文章,并查看并运行了一些示例.我注意到有些示例导入了uno,而有些则没有.它们都运行良好,但是如果我取消注释import uno,该脚本将停止工作.

I am trying to understand Python scripting in Libre Office. I've read quite a bit on the web and looked at and run some examples. I noticed that some examples import uno and some don't. They all run fine, but if I comment out import uno, that script stops working.

有人可以向我解释何时需要导入uno.

Could someone explain to me when uno needs to be imported.

谢谢,吉姆

推荐答案

您看过哪些示例?

当您需要UNO上下文时,需要UNO.这使您可以在LO或OOo上进行连接.

UNO is required when you need an UNO context. This allows you to connect on LO or OOo.

这是您需要使用UNO时的一个小示例.

Here is a small example when you need to use 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" )

这篇关于何时导入uno的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆