Skip to content

Commit 4eeecc0

Browse files
committed
Add initial app.py for Streamlit
1 parent 5612147 commit 4eeecc0

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

app.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import pyvista as pv
2+
import sys
3+
4+
st_mode = "-gui" not in sys.argv
5+
6+
print("Starting it all...")
7+
8+
if st_mode:
9+
import streamlit as st
10+
11+
st.set_page_config(layout="wide")
12+
13+
from stpyvista.utils import start_xvfb
14+
15+
if "IS_XVFB_RUNNING" not in st.session_state:
16+
start_xvfb()
17+
st.session_state.IS_XVFB_RUNNING = True
18+
19+
st.title("OpenWorm 3D Viewer")
20+
21+
22+
## Initialize a plotter object
23+
plotter = pv.Plotter(window_size=[800, 600])
24+
25+
print("Read objs...")
26+
27+
plotter.add_axes()
28+
plotter.enable_mesh_picking(show_message=True)
29+
30+
sphere = pv.Sphere(end_theta=90)
31+
plotter.add_mesh(sphere)
32+
33+
## Final touches
34+
plotter.view_isometric()
35+
# plotter.add_scalar_bar()
36+
plotter.background_color = "white"
37+
38+
print("Created the scene...")
39+
40+
if st_mode:
41+
## Pass a key to avoid re-rendering at each page change
42+
if False:
43+
from stpyvista import stpyvista
44+
45+
stpyvista(plotter, key="pv_cube")
46+
pass
47+
else:
48+
plotter.show()

0 commit comments

Comments
 (0)