Registry / web-framework / trame-vtk

trame-vtk

JSON →
library2.11.12pypypi✓ verified 87d ago

trame-vtk extends the trame web framework with components to interface with VTK (Visualization Toolkit) and/or ParaView. It enables the creation of rich visualization and data processing applications in Python, leveraging VTK's capabilities with options for both remote and client-side rendering via vtk.js. The library is actively developed, receiving regular updates in line with the trame ecosystem. The current version is 2.11.7.

pip install trame-vtk
INSTALL
IMPORT
SIG · TRAME-VTK
T
trame-vtk
web-frameworkpythonv2.11.12
Install
8.5s avg
Import
152ms
Disk
854MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.11.8 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
4/8 runs
✓ 8.89s
py 3.11
4/8 runs
✓ 8.35s
py 3.12
4/8 runs
✓ 7.53s
py 3.13
4/8 runs
✓ 7.46s
py 3.9
4/8 runs
✓ 10.26s
854MB installed
● package 854MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

vtk
from trame.widgets import vtk
Imports the trame-vtk widgets module.
VtkRemoteView
from trame.widgets.vtk import VtkRemoteView
from trame.widgets import VtkRemoteView
VtkRemoteView is part of the 'vtk' submodule within trame.widgets. In trame v3, widgets like VtkRemoteView are no longer implicitly available directly under `trame.widgets` without explicit sub-module import.
VtkLocalView
from trame.widgets.vtk import VtkLocalView
For client-side rendering using vtk.js or VTK.wasm.
vtkConeSource
from vtkmodules.vtkFiltersSources import vtkConeSource
Example of importing a specific VTK class. Other VTK objects should be imported from their respective `vtkmodules`.

This quickstart demonstrates a basic trame-vtk application displaying a VTK cone. It sets up a simple VTK pipeline, integrates it with a `VtkRemoteView` widget within a trame `VAppLayout`, and adds a slider to control the cone's resolution. It explicitly sets `server.client_type = "vue3"` for compatibility with recent `trame` versions.

import vtk from trame.app import get_server from trame.ui.vuetify3 import VAppLayout from trame.widgets import vuetify3 as v3 from trame.widgets.vtk import VtkRemoteView from vtkmodules.vtkFiltersSources import vtkConeSource from vtkmodules.vtkRenderingCore import (vtkActor, vtkPolyDataMapper, vtkRenderer, vtkRenderWindow) # ----------------------------------------------------------------------------- # VTK pipeline # ----------------------------------------------------------------------------- cone = vtkConeSource() mapper = vtkPolyDataMapper() mapper.SetInputConnection(cone.GetOutputPort()) actor = vtkActor() actor.SetMapper(mapper) renderer = vtkRenderer() renderer.AddActor(actor) renderer.ResetCamera() render_window = vtkRenderWindow() render_window.AddRenderer(renderer) # ----------------------------------------------------------------------------- # Trame setup # ----------------------------------------------------------------------------- server = get_server('trame_vtk_cone') server.client_type = "vue3" # Explicitly set for trame v3 and above state, ctrl = server.state, server.controller with VAppLayout(server, full_height=True) as layout: with v3.VContainer(fluid=True, classes='fill-height'): with VtkRemoteView(render_window) as view: ctrl.view_update = view.update ctrl.view_reset_camera = view.reset_camera @state.change('resolution') def update_resolution(resolution, **kwargs): cone.SetResolution(resolution) ctrl.view_update() @ctrl.add('reset_camera') def reset_camera(): ctrl.view_reset_camera() if __name__ == '__main__': server.start()
Debug
Known issues
breakingWith the release of `trame` v3, `trame-vtk` (along with `trame-vuetify` and other widget sets) is no longer an implicit dependency of the core `trame` package. Applications must now explicitly install `trame-vtk` and other required widget packages.
fix
Ensure your project's `pip install` commands explicitly list `trame-vtk` and any other required widget libraries (e.g., `trame-vuetify`). Example: `pip install trame trame-vuetify trame-vtk`.
affects: trame>=3.0.0
breakingStarting January 2024, `trame` v3 began defaulting to a Vue3 client. Existing applications built with Vue2-based widgets might experience breakage. While `trame` aims for backward compatibility, it's safer to explicitly declare the client type.
fix
For applications intended to use Vue2, explicitly set the client type during server initialization: `server.client_type = "vue2"`. For new applications, consider migrating to Vue3 compatible widgets and layouts, or ensure `trame-vuetify3` is used instead of `trame-vuetify`.
affects: trame>=3.0.0
gotchaWeb browser caches can cause issues when switching between Vue2 and Vue3-based trame applications, leading to unexpected rendering or behavior.
fix
When developing or testing, open browser developer tools and enable 'Disable cache' in the Network tab. Then, reload the web page. This option usually only works while the developer tools are open.
affects: All versions of trame with mixed Vue2/Vue3 applications
gotchaThe `vue-vtk-js` library (used by `trame-vtk`) uses `Math.round` for setting view sizes, which rounds half to the nearest even integer. Python's built-in `round()` function might behave differently depending on the Python version (e.g., Python 3's `round()` also rounds half to even, but custom implementations or older Python versions might vary).
fix
Be aware of potential subtle differences in rounding behavior if you are implementing custom view size calculations in Python that need to precisely match the client-side `Math.round` behavior. For most direct usage of `trame-vtk` components, this is handled internally.
affects: All versions
deprecatedKitware is actively developing `trame-vtklocal` as the default implementation for local rendering using VTK.wasm, replacing the older `vtk.js` based local rendering in `trame-vtk`. While `trame-vtk` still supports `vtk.js`, `trame-vtklocal` offers a more robust solution.
fix
For new applications or when aiming for advanced client-side rendering capabilities, consider using `trame-vtklocal`. It provides a `VtkLocalView` component similar to `trame-vtk`'s, but leverages VTK.wasm for improved fidelity and performance. Note that `trame-vtklocal>=1` is compatible with VTK 10, while `trame-vtklocal>=0.16,<1` supports VTK 9.4-9.6.
affects: trame-vtk and trame>=2.x
Upgrade
Version history
2.11.12latest on PyPI · released Jun 12, 2026
Audit
Dependencies
trame-clientrequiredCore client-side communication for trame applications. trame-vtk directly integrates with trame's client.
tramerequiredThe core trame framework. While trame-vtk is a widget library, trame v3 made it an explicit dependency for application development.
trame-vuetifyrequiredProvides Vuetify UI widgets for trame applications. Often used alongside trame-vtk for building interactive layouts, and became an explicit dependency in trame v3.
vtkoptionalThe Visualization Toolkit Python package. Required for server-side VTK pipeline execution and rendering with VtkRemoteView.
Agent activity
13 hits · last 30 days
node
10
OpenAI (training)
1
Resources
trame-vtk — pip install trame-vtk · libregistry