RV Python quickstart

RV now ships with Python in addition to Mu for scripting and extending the application cross platform. Python is a full peer to Mu as far as RV is concerned. The command API is almost identical between the two.

In order to extend RV using Python you will be making a "mode" as part of an rvpkg package—this is identical to the way it’s done in Mu and this is the method that we use internally to add new functions to RV's interface. Creation of a modes and packages is documented in the reference manual. Please read the relevant sections to understand how it’s done. Here is a very simple mode written in Python which is part of $RV_HOME/rvpkgs/pyhello-1.0.rvpkg. You can add and install $RV_HOME/rvpkgs/pyhello-1.0.rvpkg to see it working.

import rv.rvtypes
import rv.commands

class PyHello(rv.rvtypes.MinorMode):
"A simple example that shows how to make shift-Z start/stop playback"

def togglePlayback(self, event):
if rv.commands.isPlaying():
rv.commands.stop()
else:
rv.commands.play()

def __init__(self):
rv.rvtypes.MinorMode.__init__(self)
self.init("pyhello",
[("key-down--Z", self.togglePlayback, "Z key")],
None)

def createMode():
"Required to initialize the module. RV will call this function to create your mode."
return PyHello()

Documentation:

Please read the *reference manual* which is available on-line here.

or from RV's Help->RV Reference Manual menu items.

The command API is nearly identical to Mu. There are a few modules which are important to know about: rv.rvtypes, rv.commands, rv.extra_commands, and rv.rvui. These implement the base Python interface to RV.

We currently do not have separate documentation for RV's command API in Python (e.g., via Pydoc), but you can use the existing Mu Command API Browser available under RV's Help menu. The commands and extra_commands modules are basically identical between the two languages. We hope to have a Pydoc solution in the future.

If you are not familiar with Python please visit python.org to find relevant documentation, books, and tutorials. We cannot answer support questions about Python the language but we are happy to help with questions regarding RV's Python integration and Python command API.

Note: Edited to use import instead of "from".
Follow