Simple python script to get a libreoffice base field and play on vlc
Question: I've banged my head for hours on this one, and I don't understand the
LibreOffice macro api well enough to know how to make this work:

1) This 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, and this script
is fired on a button press. The video opens (with an error - see below)

Now, _how do open the path found in a given record's field labeled "path"_ \--
ie, what is being passed to python, and how do I pull that relevant bit of
info?

Further, whenever I fire this, the video plays, but I also 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 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 )]
    )
    

Please help!


Answer: For example, say the form is based on a table containing a column called
`PATH`. Assign the button's `Execute action` event to this function:

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

Documentation for Base macros is confusing, but there is some at:
<http://www.pitonyak.org/database/>

