A Python library for seamless integration between PyVista (VTK) and modern Qt Quick (QML).
Project description
PyVistaQML
A robust, thread-safe bridge between PyVista (VTK) and modern Qt 6 Quick (QML) via PySide6.
⚠️ Experimental Project ⚠️
PyVistaQML is currently an experimental library. It has been deeply tested and developed exclusively on macOS (Apple Silicon). While the underlying libraries are cross-platform, the OpenGL threading bridge may behave differently on Windows or Linux. Use with caution in production environments.
pyvistaqml is designed as a first attempt to mimic the behavior of pyvistaqt, but for the QML ecosystem. It allows you to embed high-performance 3D visualizations directly into QML applications using the familiar PyVista API.
| Single Plotter API | Multi-Plotter Sync |
|---|---|
Documentation
Full tutorials, API reference, and concept guides are available at:
Features
- Drop-in PyVista API: Inherits from
pyvista.BasePlotter. Most of your existing PyVista code will work out of the box. - Asynchronous Proxy Engine: Interact with VTK/PyVista objects synchronously in Python; the library handles the async thread routing under the hood.
- Native QML
FboComponent: Renders directly into the Qt Quick Scene Graph using a custom Framebuffer Object. - Advanced Render Control: Support for
debounce_render, custom threading decorators, and direct synchronous VTK/PyVista access when needed. - Multi-Renderer & Camera Linking: Fully supports multiple viewports and camera synchronization.
Why PyVistaQML?
Integrating VTK into QML introduces two major architectural hurdles that this library handles automatically:
- The Thread Divide: QML separates UI logic from OpenGL rendering. Modifying VTK objects from the main thread usually causes a segmentation fault. We use a Proxy Engine to route commands safely.
- The Memory Trap: Python’s garbage collector often fails to see C++ circular references in VTK. We provide an aggressive Synchronous Teardown to prevent GPU memory leaks.
Prerequisites
pyvistaqml requires Python >= 3.10, PySide6 >= 6.4 (Qt5 not supported), and PyVista >= 0.44.
1. Standard Installation
For most users, installing via standard package managers is recommended.
# Via PyPI
pip install pyvistaqml
# Via Anaconda
conda install -c mosaic -c conda-forge pyvistaqml
2. Development / From Source
If you want to contribute, run tests, or use the latest development version, clone the repository and use either Conda or Pixi:
git clone https://gitlab.inria.fr/mosaic/pyvistaqml.git
cd pyvistaqml
# Option A: Conda
conda create -n pyvistaqml python=3.12
conda activate pyvistaqml
pip install -e ".[test]"
pytest
# Option B: Pixi
pixi install -e py312
pixi run -e py312 pytest
🚀 Quick Start
For a detailed walkthrough on integrating Python backend logic with a QML interface using pyvistaqml, please refer to:
Acknowledgments
This project is a higher-level framework built upon the foundational work of:
- Nicanor Romero: Original C++/QML integration.
- Dao Duc Tung: Initial Python port of the OpenGL framebuffer bridge.
pyvistaqml is distributed under the LGPLv3 license. See LICENSE.md for details.
Included Examples
The repository includes comprehensive examples to help you get started:
-
examples/base_plotter_methods/: A fully featured test bench demonstrating how to use almost allBasePlottercapabilities inside a QML UI. It covers adding 3D geometry, applying VTK widgets (sliders, planes, boxes), handling complex picking events, and manipulating the camera. -
examples/multiplotter/: Demonstrates advanced architecture by dynamically spawning a grid of multiple 3D viewports. It highlights hardware-accelerated camera synchronization (link_cameras), dynamic QML Repeater integration, and memory tracking.
Troubleshooting
VTK & Conda-Forge Warnings / Crashes (Linux & macOS)
Recent Conda versions of VTK (>=9.5) use the viskores engine, which can cause warnings, errors, or even segfaults. While it tends to be robust on macOS Silicon, Linux systems (especially with CUDA) are highly prone to crashing.
Solution: We strongly recommend using pip to install vtk for maximum stability across all hardware.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyvistaqml-0.2.4.tar.gz.
File metadata
- Download URL: pyvistaqml-0.2.4.tar.gz
- Upload date:
- Size: 44.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c94f4893c5b7fdf440144ae95b3026471cc0351abfcc6c77e8f5c23b451509ac
|
|
| MD5 |
524c07ad78567b2d589d661ac7d6c25a
|
|
| BLAKE2b-256 |
105fc0e6aea91a5b836a8ad099f2d17aed0372b0eb5af8fc27782e0ac73a40d5
|
File details
Details for the file pyvistaqml-0.2.4-py3-none-any.whl.
File metadata
- Download URL: pyvistaqml-0.2.4-py3-none-any.whl
- Upload date:
- Size: 37.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9a0be85dd1d4b9a69005a429d1115261a619f68d84b67de04f8fda7b5d4606b
|
|
| MD5 |
abcd0fb3cf924ed2ee1a77593e98a40f
|
|
| BLAKE2b-256 |
512f24dae80fb6893b567e1701e99155a72dda169c8cc68d3169c64f7d6d263d
|