Skip to main content

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

Code Web App
Write some python code And get a web app

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

paraview_trame_components-0.10.3.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

paraview_trame_components-0.10.3-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file paraview_trame_components-0.10.3.tar.gz.

File metadata

File hashes

Hashes for paraview_trame_components-0.10.3.tar.gz
Algorithm Hash digest
SHA256 3a4d85189d312537b19d2eb7e19279bda000a30fa218a750fa468ddc96355594
MD5 6d54c89931bebcf14d0eeb43861111fa
BLAKE2b-256 849ba0bb6b75c867382d0b2065a07005977e446bb81f6ece8611bf939960f98d

See more details on using hashes here.

Provenance

File details

Details for the file paraview_trame_components-0.10.3-py3-none-any.whl.

File metadata

File hashes

Hashes for paraview_trame_components-0.10.3-py3-none-any.whl
Algorithm Hash digest
SHA256 401d6f8a4e47f566bd00753b88899dfe0a4df2e1ab669e5c4ca13473b72b522c
MD5 05108ddd57088daa84e47b2e3ce5a4c8
BLAKE2b-256 100ee46052682c756932ee5c4c0155b7424a202a26a0479ec5ae2420d3e8137b

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page