GithubHelp home page GithubHelp logo

paraview-trame-components's Introduction

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_width_slider.py
$PVPYTHON --force-offscreen-rendering ./examples/wavelet-contour-state.py
$PVPYTHON --force-offscreen-rendering ./examples/pipeline.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

paraview-trame-components's People

Contributors

actions-user avatar jourdain avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.