添加LibreOffice自定义Python扩展报错,寻求修复方法
修复步骤
1. 修正datalink.py中的方法调用错误
你在trigger方法里直接实例化MessageBoxService类,但该类的弹窗逻辑封装在**静态方法Show**中,并非通过实例化调用。修改代码如下:
def trigger(self, args): MessageBoxService.Show("Hello World!!! Args: " + args, "Info")
2. 更新manifest.xml,添加Python模块路径声明
当前manifest.xml仅声明了datalink.py和Addons.xcu,未包含存放messageboxservice.py的pythonpath目录,导致LibreOffice无法找到该模块。添加对应路径声明:
<?xml version="1.0" encoding="UTF-8"?> <manifest:manifest xmlns:manifest="http://openoffice.org/2001/manifest"> <manifest:file-entry manifest:full-path="Addons.xcu" manifest:media-type="application/vnd.sun.star.configuration-data"/> <manifest:file-entry manifest:full-path="datalink.py" manifest:media-type="application/vnd.sun.star.uno-component;type=Python"/> <manifest:file-entry manifest:full-path="pythonpath/" manifest:media-type="application/vnd.sun.star.python.path"/> </manifest:manifest>
3. 验证扩展打包完整性
打包.oxt文件时,必须确保包含以下所有内容:
Addons.xcudatalink.pypythonpath/目录(及其子目录services/下的messageboxservice.py)manifest.xml
完成以上修改后,重新打包扩展并安装,即可解决加载错误。
内容的提问来源于stack exchange,提问作者Anton
相关产品推荐
相关产品推荐

