简单 python 脚本获取 libreoffice 基础字段并在 vlc 上播放

Simple python script to get a libreoffice base field and play on vlc

我已经为此苦苦思索了几个小时,但我对 LibreOffice 宏的理解还不够api,不知道如何实现:

1) 此脚本适用于 python:

#!/usr/bin/env python3
import subprocess 
def play_vlc(path="/path/to/video.avi"):
    subprocess.call(['vlc', path])
    return None
play_vlc("/path/to/video.avi")

2) 我有 python 脚本在 LibreOffice Base 中运行良好,按下按钮时会触发此脚本。视频打开(出现错误 - 见下文)

现在,如何打开在标记为 "path" 的给定记录字段中找到的路径——即传递给 python 的内容,以及我如何提取相关信息?

此外,每当我启动它时,视频都会播放,但我也会得到:

com.sun.star.uno.RuntimeExceptionError during invoking function play_vlc in module file:///usr/lib/libreoffice/share/Scripts/python/vlc.py (<class 'TypeError'>: Can't convert 'com.sun.star.lang.EventObject' object to str implicitly
  /usr/lib/python3.5/subprocess.py:1480 in function _execute_child() [restore_signals, start_new_session, preexec_fn)]
  /usr/lib/python3.5/subprocess.py:947 in function __init__() [restore_signals, start_new_session)]
  /usr/lib/python3.5/subprocess.py:557 in function call() [with Popen(*popenargs, **kwargs) as p:]
  /usr/lib/libreoffice/share/Scripts/python/vlc.py:8 in function play_vlc() [subprocess.call(['vlc', path])]
  /usr/lib/libreoffice/program/pythonscript.py:870 in function invoke() [ret = self.func( *args )]
)

请帮忙!

例如,假设表单基于包含名为 PATH 的列的 table。将按钮的 Execute action 事件分配给此函数:

def playvlc_button_pressed(oEvent):
    oForm = oEvent.Source.getModel().getParent()
    lNameCol = oForm.findColumn('PATH')
    sPath = oForm.getString(lNameCol)
    play_vlc(sPath)

基本宏的文档令人困惑,但在以下位置有一些: http://www.pitonyak.org/database/