Simple python script to get a libreoffice base field and play on vlc -
i've banged head hours on one, , don't understand libreoffice macro api enough know how make work:
1) script works in 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) i've got python scripts working fine in libreoffice base, , script fired on button press. video opens (with error - see below)
now, how open path found in given record's field labeled "path" -- ie, being passed python, , how pull relevant bit of info?
further, whenever fire this, video plays, get:
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 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) 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 )] )
please help!
for example, form based on table containing column called path
. assign button's execute action
event function:
def playvlc_button_pressed(oevent): oform = oevent.source.getmodel().getparent() lnamecol = oform.findcolumn('path') spath = oform.getstring(lnamecol) play_vlc(spath)
documentation base macros confusing, there at: http://www.pitonyak.org/database/
Comments
Post a Comment