Get started with PrestoPlot Python API
In this section you will get familiar with basic PrestoPlot Python development and main steps to interact with PrestoPlot from Python.
Install the PyPrestoPlot package
To use PrestoPlot from a python script, you must use the PyPrestoPlot python package. This package will give you access to the PrestoPlot API from a Python script.
The recommended way is to install it in a Python virtual environment.
With venv and pip
# Create a virtual environment
python -m venv .venv
# Activate the environment (windows)
.venv\scripts\activate
# Activate the environment (linux)
.venv/bin/activate
# Install this package (windows)
pip install pyprestoplot-26.6-py3-none-win_amd64.whl
# Install this package (linux)
pip install pyprestoplot-26.6-py3-none-manylinux_2_12_x86_64.whl
With uv
# Create a python environment for your project
uv venv
# Activate the environment (windows)
.venv\scripts\activate
# Activate the environment (linux)
.venv/bin/activate
# Install this package (windows)
uv pip install pyprestoplot-26.6-py3-none-win_amd64.whl
# Install this package (linux)
uv pip install pyprestoplot-26.6-py3-none-manylinux_2_12_x86_64.whl
Then you have an environment ready to use PrestoPlot. Keep in mind you have to activate the environment again if you close your terminal.
Basic usage
Your Python script have to first import the PrestoPlot class from pyprestoplot module, which provides access to the PrestoPlot features.
When you create an instance of PrestoPlot, you give the PrestoPlot binary path ; that's this version of PrestoPlot that will be used.
from pyprestoplot import PrestoPlot
# Start a non-visible PrestoPlot instance, using the embedded PrestoPlot version.
pp = PrestoPlot()
# Start a visible PrestoPlot instance, using the embedded PrestoPlot version.
pp = PrestoPlot(visible=True)
# Start a visible PrestoPlot instance, using an external PrestoPlot version.
pp = PrestoPlot("/your/own/prestoplot.lnx", visible=True)
# Then you can interact with it
print(pp.version)
Now the pp object is the entry point to pilot this instance of PrestoPlot through the API.
For stability aspects over PrestoPlot versions, please refer to API versions page.
There is basically three ways to interact with PrestoPlot and perform actions :
- Pilot PrestoPlot by instructing commands to load data files, load models or graphs, generate images or reports, create or modify graphs, etc
- Adding custom buttons or entry menu in the User Interface. When the user click on them, your code will be executed. Use the UserInterface class to do so.
- React to PrestoPlot events. PrestoPlot will execute your code on agreed hooks, when some events occurs. You will find more information in the Public Callbacks sections of classes descriptions.
The entry point to interact with PrestoPlot is the PrestoPlot class. It gives access to high level and application features. For example, to get the DatasetManager and create a dataset, you simply need :
dsm = pp.datasetManager
dataset = dsm.createDataset("MyNewDataset")
Go further
To further, you can go to the python samples page, then have a look at the whole documentation and the API reference.