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.14.0.tar.gz (29.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

paraview_trame_components-0.14.0-py3-none-any.whl (36.7 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for paraview_trame_components-0.14.0.tar.gz
Algorithm Hash digest
SHA256 595232079d701e18791961f8d7e51fffee2ae081fceba8cc9293f04a08b50043
MD5 ab3347f871a980bf051c9dd77b1704b2
BLAKE2b-256 5f802a5bf82e54fb7a8fa7a1840e23d651f6583d5399adfd152780d4c49ee8ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for paraview_trame_components-0.14.0-py3-none-any.whl
Algorithm Hash digest
SHA256 488cd81c7ec5373d30f4971fb82b7b7c807551fce851efb1618f025796a7abed
MD5 dd1ca23218d42840afabde45d0c3b970
BLAKE2b-256 e821994eb388081125cc8de00055cf7c51638ba2d048b747a062c2e819664b94

See more details on using hashes here.

Supported by

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