我已經在這一個上打了我好幾個小時的頭,並且我不明白LibreOffice宏api已經足夠知道如何完成這項工作:簡單的python腳本來獲取libreoffice base字段並在vlc上玩
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基地做工精細,並且該腳本上的按鈕按下開火。該視頻打開(有一個錯誤 - 見下文)
現在,如何打開在給定記錄的字段中找到的路徑標記爲「路徑」 - 即什麼是傳遞給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'不包含字符串,但一個' com.sun.star.lang.EventObject'。如何發佈錯誤實際發生的代碼?發佈工作代碼對於調試並不是很有用。 –
嗨rawling - 那就是它的代碼。有些東西正在傳遞給導致該錯誤的函數(我猜) - 具有諷刺意味的是,我懷疑這是我需要的信息來獲取我想要的路徑,但我無法確定... – Trees4theForest