Macro components for ParaView
Project description
ParaView Trame Components
This project gather helper classes that can be used with ParaView to create quickly and simply web solution for interacting with your data.
Usage example
The ./examples/
directory gather simple Python scripts using ParaView and exposing them as standalone trame applications.
Virtual Environment setup
Since ParaView does not come with trame, you need to create a virtual environment that brings all the missing dependency for paraview to use.
# Create and activate venv
python3.10 -m venv .venv
source .venv/bin/activate
# Install published package
pip install paraview-trame-components
# Let ParaView know about the location of that venv
export PV_VENV=$PWD/.venv
Running examples
# Adjust path to point to your ParaView executable
export PVPYTHON=/Applications/ParaView-5.12.0.app/Contents/bin/pvpython
# Run the scripts
$PVPYTHON --force-offscreen-rendering ./examples/cone.py
$PVPYTHON --force-offscreen-rendering ./examples/cone-with-slider.py
$PVPYTHON --force-offscreen-rendering ./examples/wavelet-contour-state.py
$PVPYTHON --force-offscreen-rendering ./examples/pipeline.py
$PVPYTHON --force-offscreen-rendering ./examples/selection.py
Scripts structure
Each script add import paraview.web.venv
at the top to enable your virtual environment via the PV_VENV
environment variable.
Then we use the ptc (ParaView Trame Components) package to quickly create a trame application to view the data.
The wavelet-contour-state.py
script was created by ParaView when saving its state as a Python file. Then we added few lines at the end to create an interactive web viewer.
Check code
# one time
pip install ".[dev]"
pre-commit install
# check but automatic on commit
pre-commit run --all-files
ParaView code example
import paraview.web.venv
from ptc import Viewer
from paraview import simple
cone = simple.Cone()
simple.Show()
simple.Render()
# Make it a web app
web_app = Viewer()
web_app.start()
And if you want to add some UI
import paraview.web.venv
from paraview import simple
from ptc import Viewer
from trame.widgets.vuetify3 import VSlider
cone = simple.Cone()
simple.Show()
simple.Render()
# Make it a web app
web_app = Viewer()
with web_app.side_top:
VSlider(
v_model=("resolution", 6),
min=3, max=60, step=1,
)
@web_app.state.change("resolution")
def on_resolution_change(resolution, **kwargs):
cone.Resolution = resolution
web_app.update()
web_app.start()
Example in image
Write some python code | And get a web app |
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file paraview_trame_components-0.12.1.tar.gz
.
File metadata
- Download URL: paraview_trame_components-0.12.1.tar.gz
- Upload date:
- Size: 21.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f91ec028dc11d9dd6953271d77a78d776c4fd7024b566d8c031e99a03ba40d3e |
|
MD5 | 565a06bd26a4d58b7c74e04ec01cbc14 |
|
BLAKE2b-256 | e4d79efc58a1f1fa0ffd49bcc37e713039ce8fc2acbf7fea36f04bd2e4ffca89 |
File details
Details for the file paraview_trame_components-0.12.1-py3-none-any.whl
.
File metadata
- Download URL: paraview_trame_components-0.12.1-py3-none-any.whl
- Upload date:
- Size: 24.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45209977d83356f9231cb310d90a2e0ada6d641d0a07aff1581a78d11674a772 |
|
MD5 | e3200d3d9a306fc8708fce0cd19dc533 |
|
BLAKE2b-256 | 22f2da42aeb67c7edbb2a3a27bb7bb8ace6a4faa195f87b56daf6dc1bf18730d |