Skip to main content

Streamlit PyVista

PyPI version Read the Docs

A Streamlit component that allow support for new pyvista viewer backend : Trame.

Installation instructions

pip install streamlit-pyvista

Usage Instructions

import streamlit as st
from streamlit_pyvista.mesh_viewer_component import MeshViewerComponent


def main():
    st.title("Simple Streamlit App With Pyvista Viewer")

    mesh_viewer = MeshViewerComponent("assets/plate_hole.vtu")
    mesh_viewer2 = MeshViewerComponent("assets/plate_hole.vtu")

    mesh_viewer.show()
    mesh_viewer2.show()


if __name__ == "__main__":
    main()

Note that instead of a file path it's also possible to pass an array of paths to display a sequence of files. Only local file paths are supported.

This viewer leverage the capabilities of the new pyvista backend Trame, beyond the nice design revamp, it also supports remote rendering through trame's websocket based rendering.

Decimation

For large meshes (more than 6000 cells by default, see the STREAMLIT_PYVISTA_DECIMATION_THRESHOLD environment variable), the viewer automatically computes a decimated version of the mesh ("thumbnail") that is displayed by default to keep the interface fast. A checkbox in the viewer lets you switch to the original resolution: the full mesh is then loaded in the background while a spinner is shown, so the interface never freezes.

While the server is busy (loading meshes, decimating, computing scalar bounds) a spinner is displayed on top of the plotter. When a sequence of files is loaded, this spinner turns into a progress bar showing e.g. "Loading mesh 3/11".

Package documentation

You can find the automatic documentation generated with sphinx here

Workflow overview

This package has 3 different components:

  • The Streamlit component
  • The Trame viewers
  • A "Server manager"

Streamlit component

This pyvista new backend requires now to have its own server for each instance of a pyvista plotter. This means that the streamlit component can be as simple as an iframe and displayed in the app and can use a simple api to communicate with the trame server and the server manager

Trame viewers

The Trame viewers are the servers that are embedded in the streamlit app, it has exposed api endpoints that allow the component to communicate with the server for action such as loading a mesh in the viewer.

Server manager

As said earlier, the trame viewers can only display one plotter at a time which means that if we want to display multiple plotters we need multiple servers. The job of the Server manager is to control how many trame viewers exists, if they need to killed or if they can be reused for other viewers

Workflow

These 3 components interact the following manner:

  1. A MeshViewerComponent is created and notify a ServerManager that it needs a viewer.
  2. The ServerManager look if he have idling trame viewer anf if not, it start a new server.
  3. The ServerManager specify the endpoints of the server that can be used to the MeshViewerComponent
  4. The MeshViewerComponent directly communicate with the api of the trame viewer via the endpoints specified by the ServerManager

Metadata

Release files for streamlit-pyvista 0.0.24

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for streamlit-pyvista 0.0.24
File Size Uploaded Provenance
streamlit_pyvista-0.0.24.tar.gz 4.9 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for streamlit-pyvista 0.0.24
File Interpreter ABI Platform
streamlit_pyvista-0.0.24-py3-none-any.whl Python 3 none any Details

Total release size: 5.0 MB

Release files / streamlit_pyvista-0.0.24.tar.gz

Download URL streamlit_pyvista-0.0.24.tar.gz
Size 4.9 MB
Tags Source
SHA-256 checksum
How to use checksums
07502614cede79d206dfba0f175f61ed02e07a57ca84102abc7c45b7fdcba9f1
BLAKE2b-256 checksum
How to use checksums
d4a30ac94d244ef6f9d4c92a6064acb9aa1f36d3881ce58cb4b66eb0e6ca714a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / streamlit_pyvista-0.0.24-py3-none-any.whl

Download URL streamlit_pyvista-0.0.24-py3-none-any.whl
Size 62.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ce291f7fe3c971aebdaf1c9c081b361048bda8799599e80d536076b703e01d3
BLAKE2b-256 checksum
How to use checksums
264fbf9c2467da65a2d5d2d57f2690986b4548d64aebddeeec466cf89f2524c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for streamlit-pyvista 0.0.24

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page