Skip to content

About

PyVista <-> Trame Integration

Resources

Stars

4 stars

Watchers

2 watching

Forks

Repository files navigation

trame-pyvista

Trame interface for PyVista. Provides web-based 3D viewers, Jupyter backends, scene exporters, and a Sphinx directive for embedding interactive plots in docs.

This package was extracted from the pyvista.trame subpackage so the trame stack can release on its own cadence. PyVista discovers installed functionality through entry points, so existing user code keeps working once trame-pyvista is installed.

Install

pip install trame-pyvista

For Jupyter:

pip install "trame-pyvista[jupyter]"

The notebook widgets are anywidgets. When the Jupyter server runs in a separate environment from the kernel (JupyterHub, nb_conda_kernels), install anywidget in the server environment too.

For marimo:

pip install "trame-pyvista[marimo]"

What you get

  • Jupyter backends: trame, server, client, html. Registered with PyVista via the pyvista.jupyter_backends entry-point group, so pv.set_jupyter_backend('trame') works once trame-pyvista is installed.

  • marimo: with PyVista 0.50 or newer (pip install "pyvista[marimo]"), pl.show() and mesh.plot() render inline and jupyter_backend or pv.set_jupyter_backend picks the backend, as in Jupyter. With older PyVista, end a cell with pl.trame.show(mode=...) instead. html works in any marimo session, while trame, server and client need the browser on the machine running marimo. See examples/marimo/viewer.py.

  • Plotter views: PyVistaLocalView, PyVistaRemoteView, PyVistaRemoteLocalView for embedding in trame apps.

  • plotter.trame namespace: registered as a PyVista plotter component so exporters live under the trame namespace:

    import pyvista as pv
    
    pl = pv.Plotter()
    pl.add_mesh(pv.Sphere())
    pl.trame.export_vtksz('scene.vtksz')
    pl.trame.export_html('scene.html')
  • Sphinx directive: trame_pyvista.sphinx_ext provides the offlineviewer directive used by PyVista docs to embed exported .vtksz scenes. Add to conf.py:

    extensions = ['trame_pyvista.sphinx_ext']

Usage

import pyvista as pv

pv.set_jupyter_backend('trame')
pl = pv.Plotter()
pl.add_mesh(pv.Wavelet())
pl.show()

Custom UI:

from trame_pyvista import plotter_ui

ui = plotter_ui(plotter, mode='trame')

See examples/ for runnable scripts covering local/remote views, custom UIs, and toolbar customization.

Development

Uses uv and just:

just sync         # create venv and install dev deps
just test         # unit tests
just test-playwright  # Sphinx + browser integration tests
just lint         # pre-commit (ruff, etc.)
just typecheck
just build

License

MIT. See LICENSE.

About

PyVista <-> Trame Integration

Resources

Stars

4 stars

Watchers

2 watching

Forks

Releases

Used by

Contributors

Languages