Trame#

Kitware’s Trame is an open-source platform for creating interactive and powerful visual analytics applications. Based on Python, and leveraging platforms such as VTK, ParaView, and Vega, it is possible to create web-based applications in minutes.

What is Trame?#

Trame is a Python framework for building reactive web applications.

  • All the logic and UI definition can be done in plain Python

  • Runs on laptops, desktops, clusters, and the cloud while displaying everywhere (phone, tablet, laptop, workstation)

Learn more about Trame

Trame Documentation

Gain hands on experience with Trame through the tutorial.

Trame Tutorial

3D visualization in web applications#

PyVista and Trame work excellently together to provide a cutting-edge capabilities for 3D visualization in reactive web applications.

  1. Trame provides a high-level framework for building reactive, stateful web applications

  2. PyVista provides a high-level framework for 3D visualization, exposing VTK in a “Pythonic” manner

High-level framework 1 + high-level framework 2 = a streamlined approach to making powerful web applications with 3D visualization front and center.

The following code creates a simple Trame application with a PyVista plotter embedded in the UI. This code can be used as a base for building all of your Trame applications with PyVista as it contains all of the boilerplate code needed to get started.

import pyvista as pv
from pyvista import examples
from pyvista.trame.ui import plotter_ui
from trame.app import get_server
from trame.ui.vuetify3 import SinglePageLayout

# Always set PyVista to plot off screen with Trame
pv.OFF_SCREEN = True

server = get_server()
state, ctrl = server.state, server.controller

mesh = examples.load_random_hills()

pl = pv.Plotter()
pl.add_mesh(mesh)

with SinglePageLayout(server) as layout:
    with layout.content:
        # Use PyVista's Trame UI helper method
        #  this will add UI controls
        view = plotter_ui(pl)

server.start()
A simple Trame application with PyVista

Note

PyVista’s Jupyter backend is powered by Trame! If you’ve been using PyVista in Jupyter lately, you’ve been using Trame all along – our Jupyter backend is a micro Trame application.

Trame applications#

Using an existing app

from trame.app.demo import Cone

app = Cone("demo")
await app.ui.ready
app.ui

Try Pan3D: pip install pan3d

from pan3d import DatasetBuilder

builder = DatasetBuilder(viewer=True)

builder.import_config('example_sst_xarray.json')

# Show viewer in cell output
await builder.viewer.ready
builder.viewer.ui

Exercises#

Do not run these examples in Jupyter but rather as standalone scripts.

Getting started

Getting started

Simple Trame App

Simple Trame App

Control the Color of an Actor

Control the Color of an Actor

Using VTK/PyVista and Trame

Using VTK/PyVista and Trame

Control Scalar Array

Control Scalar Array

Control Scalar Range

Control Scalar Range

Using VTK, PyVista, and Trame

Using VTK, PyVista, and Trame

Open Mesh File

Open Mesh File

Gallery generated by Sphinx-Gallery