A Streamlit component that allow support for new PyVista viewer backend: Trame.
Project description
Streamlit PyVista
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(
"https://gitlab.com/dcsm/streamlit-pyvista/-/raw/main/examples/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 or a url it's also possible to pass an array of link or path to display a sequence of files.
This viewer leverage the capabilities of the new pyvista backend Trame
, beyond the nice design revamp,
it also supports remote rendering.
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 manger
Trame viewers
The Trame viewers are the servers that are embeded 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:
- A
MeshViewerComponent
is created and notify aServerManager
that it needs a viewer. - The
ServerManager
look if he have idling trame viewer anf if not, it start a new server. - The
ServerManager
specify the endpoints of the server that can be used to theMeshViewerComponent
- The
MeshViewerComponent
directly communicate with the api of the trame viewer via the endpoints specified by theServerManager
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
Hashes for streamlit_pyvista-0.0.16-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebfe5a282b797408d0ce1e8e4dad715475a15037a12af0fc2ab8f214d668b74f |
|
MD5 | b2315da1dc02a4368b827828bc3f4696 |
|
BLAKE2b-256 | 5a6676c8a1f4ec064eae60a9eb634fb0a3f6dd674c5d1b553950fbb453378dcf |