首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在宏开发期间将python脚本“部署”到LibreOffice的首选方法?

在宏开发期间将python脚本“部署”到LibreOffice的首选方法?
EN

Stack Overflow用户
提问于 2012-05-25 01:10:35
回答 2查看 723关注 0票数 2

至少在用python为Linux上的LibreOffice / OpenOffice开发宏时,我读到过必须将py脚本放在一个特定的目录中。

Python LibreOffice/OOo开发人员有没有首选的方法来部署这些脚本,或者有没有其他方法可以在LibreOffice/OOo中指定您想要这些脚本的位置?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-05-25 02:51:48

也许一个很好的方法是熟悉Python安装工具本身(http://packages.python.org/an_example_pypi_project/setuptools.html),并编写一个适当的setup.py脚本,将所有需要的文件放在适当的目录中。

您的宏甚至可以与"easy_install“Python框架一起安装

票数 1
EN

Stack Overflow用户

发布于 2017-02-08 17:05:19

为避免重新加载已更改的宏(即使已将其部署到正确的文件夹中),您可以在开发期间让LibreOffice侦听套接字:

代码语言:javascript
复制
import uno

def getModel():
    # 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)

    # connect to the running office
    context = resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
    manager = context.ServiceManager

    # get the central desktop object
    desktop = manager.createInstanceWithContext("com.sun.star.frame.Desktop", context)

    # access the current writer document
    return desktop.getCurrentComponent()

我解释了当您准备好在this article中部署时如何替换这个开发属性

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10742188

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档