Welcome to Mari’s documentation!

Welcome to the Mari Python API documentation. If you are new to Python, you should definitely check out the on-line tutorial:

Mari’s Python console works in a very similar way to a standard Python interpreter. For more details, please see Python ‣ Readme on the menu in Mari.

Python Quick Start

Most functions in Mari are performed by using a manager object. These managers perform many operations themselves, and also provide access to other types of objects. For example, the project manager object is mari.projects, and calling its list() method provides ProjectInfo objects to describe the projects that are available. The manager objects are listed in the Variables section below.

If you understand the basics of Python and want to try using it to get Mari to do something, here are some examples of how to perform some common tasks.

To open a project:

mari.projects.open('your_project_name')

To get a list of the available projects:

mari.projects.list()

To get the currently selected geometry object:

mari.geo.current()

To get a list of the image sets on the current geometry object:

mari.geo.current().imageSetList()

To undo the last action:

mari.history.undo()

To add a Python script to the menu:

action = mari.actions.create('Test Action', 'mari.utils.message("Hello")')
mari.menus.addAction(action, 'MainWindow/Test Menu')

To get access to the current camera:

mari.canvases.current().camera()

To get access to the paint buffer:

mari.canvases.paintBuffer()

To create an example PySide widget:

button = PySide.QtGui.QPushButton('Push Me')
button.show()

To be notified when a script error occurs:

def on_error(message):
    print('Script error:', message)
script_manager = mari.ScriptManager()
script_manager.errorOccurred.connect(on_error)

To create an example QML widget:

view = QQuickView()
container = QWidget.createWindowContainer(view)
host = QWidget()
layout = QVBoxLayout(host)
layout.addWidget(container)
palette = mari.palettes.create("QML Palette", host)
palette.setBodyWidget(host)

There are also a considerable number of example scripts documented in the mari.examples module. You can look at the source code of these to get some further ideas. Please note though that the source code is only useful for the examples; the source code for the “mari” module is simply a set of generated function stubs with doc strings provided for structural reasons.

Most functions in Mari are performed by using a manager object, as above.. These managers perform many operations themselves, and also provide access to other types of objects. For example, the project manager object is mari.projects, and calling its list() method provides ProjectInfo objects to describe the projects that are available. The manager objects are listed in the Variables section below.

Mari’s Python API uses PySide. Reference documentation can be found at: - The PySide project - The Qt library

Python API Reference

mari

Mari docs package.

mari.current

Contains convenience functions for easy access to currently-active elements.

mari.examples

Contains example functionality implemented to demonstrate the use of the API.

mari.session

A collection of tools for importing/exporting live session data to/from Mari.

mari.system

Contains larger chunks of standard Mari functionality.

mari.utils

Contains small utility functions for use by all other areas of Python functionality.

Custom Shader API Reference

C API Reference