Python Api

Interaction between python and the c++ app is done using the PeelApp.cmd module.

For example:

from PeelApp import cmd
print (cmd.getCurrentFile())

will print the current .peelcap file the application is saving to.

Class Documentation

class PeelPython : public QObject

This is the interface from python commands to the c++ application.

To access these functions in python use:

from PeelApp import cmd
cmd.load("test.peelcap")
...

Public Functions

QList<QString> selectedTakes()

Returns the names of the current selected takes in the take list

void write(const QString&)

Write a message to the log window. sys.stdout is redirected to here.

When peelcapture first starts it calls:

from PeelApp import cmd
import sys
sys.stdout=cmd
sys.stderr=cmd
to redirect the output to the main app window.

void flush()

sys.flush is redirected to here. Doesn’t do anything currently.

void load(QString)

Load a peelcap file.

void save(QString)

Save a peelcap file.

void setDevices(QList<Device*>)

Set the current active device names and current status in the ui.

void updateDevice(Device*)

update a specific device in the ui

void setDeviceData(QString)

Set the json data to be saved to the peelcap file for the device.

QString getDeviceData()

get the data for the devices as a json string

void clearDevices()

Clear device data.

void addDevice(Device)

Deprecated:

Register a new device - use setDevices() instead.

inline Device *newDevice()

Helper method to create a new Device object.

void setSubjects(const QStringList &subjects)

set the list of subjects shown in the ui

void clearShotList()

Clear the shot list table - see shotlist.py.

void addShot(QStringList)

Add a row to the shot list table - see shotlist.py.

void addShot(QString, QString)

Add a row to the shot list table - see shotlist.py.

void setAudioSettings(int sampleRate, int sampleSize)

Change the audio settings.

void startAudioRecording(QString deviceName, QString takeName)

Start recording a wav file to dataDirectory/deviceName/takeName.wav.

void stopAudioRecording()

Stop recording audio.

QString currentAudioDevice()

Get the name of the audio recording device that is currently active.

void setCurrentAudioDevice(QString)

Set the current audio device.

void motiveCommand(QString)

Send a command to the Naturalpoint natnet motive api.

const QObject *getMainWindow()

Get the QObject for the main window to use to parent guis to or add menu’s.

For example to add a custom menu to the main window:

from PySide6 import QtWidgets
from PeelApp import cmd
def say_hello():
    QtWidgets.QMessageBox.information(cmd.getMainWindow(), "Hello", "Have a nice day!")

menu_bar = cmd.getMainWindow().menuBar()
foo_menu = menu_bar.addMenu("Foo")
action = foo_menu.addAction("Test")
action.triggered.connect(say_hello)

QString getCurrentFile()

Get the current peelcap file.

QString getDataDirectory()

Get the current save data directory.

void setDataDirectory(QString)

Python call to set the current directory in the main app.

QMap<QString, QString> getMetaValues()

Get a list of custom name=value attributes saved in the .peelcap file.

void setMetaValue(QString, QString)

Set a name=value to save in the peelcap fiel.

void clearMetaValues()

Clear the custom attributes.

void showLightbulb(bool)

Show the device lightbulb icon.

void lightbulbOn(bool)

Change the lightbulb to be on/off.

void writeLog(QString)

write a message to the logfile, but not the script editor. Useful for spammy status messages.

QStringList takes()

list of the current take names, used for downloading files from devices

int createDevice(const QString &idenifier)

create plugin device

bool configureDevice(int deviceId, const QString &settings)

configure a plugin device

QString deviceCommand(int deviceId, const QString &cmd)

send the plugin a message or command and get a response

void setDeviceEnabled(int deviceId, int state)

change the state of a dll device 0 - disabled, 1 - enabled

int getDeviceEnabled(int deviceId)

get the device enable state

bool deleteDevice(int deviceId)

remove a plugin device

QStringList getPluginDevices()

get a list of the devices available as plugins

void setUserData(QString take, QString data)

Set user data for a take.

int getTakeCount()

Get take count.

QMap<QString, QString> getTakeData(int id)

Get take data.

void record()

Start Recording.

void play()

Start Recording.

void stop()

Stop Recording.

void createMark(QString)

Create Mark.

void prev()

Move to previous take.

void next()

Move to next take.

void prevShot()

Move to previous shot.

void nextShot()

Move to next shot.

void gotoShot(int)

Go to a specific shot#

void setShot(QString)

Set Take.

void setTakeNumber(int)

Set Take Number.

void setTag(QString)

Set Tag.

QWidget *timecodeWidget(QWidget *parent, QString fontName, QString fontStyle)

Create a timecode widget.

QString getTimecode()

Get current Timecode value.

void notifySlateClosed()

Notify the app the slate window has been closed.

Public Members

QMap<QString, QString> currentConfig

Dictionary of name => value config.

Keys are: ShotgunUrl, ShotgunScript, ShotgunKey, DataDirectory, FTrackUrl, FTrackUser, FTrackKey This data is populated by the main app when the settings are loaded or changed. Changing these values will not update the settings.

Plugins *plugins

@Private

TakeTreeModel *takeModel

@Private