Skip to content

Commit 1d6d62e

Browse files
Mike ProsserMike Prosser
authored andcommitted
Add more samples, to make testing with multiple panels easier.
1 parent d40e02a commit 1d6d62e

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

examples/sample/sample_2.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""This example demonstrates how to open/update a Streamlit application using nipanel package."""
2+
3+
import pathlib
4+
5+
import nipanel
6+
7+
script_path = pathlib.Path(__file__)
8+
panel_script_path = str(script_path.with_name("sample_panel_2.py"))
9+
10+
panel = nipanel.StreamlitPanel(
11+
panel_id="sample_panel_2",
12+
streamlit_script_path=panel_script_path,
13+
)
14+
panel.set_value("sample_string", "Hello, World! #2")
15+
panel.set_value("sample_int", 42)
16+
17+
print(f"Panel URL: {panel.panel_url}")

examples/sample/sample_3.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""This example demonstrates how to open/update a Streamlit application using nipanel package."""
2+
3+
import pathlib
4+
5+
import nipanel
6+
7+
script_path = pathlib.Path(__file__)
8+
panel_script_path = str(script_path.with_name("sample_panel_3.py"))
9+
10+
panel = nipanel.StreamlitPanel(
11+
panel_id="sample_panel_3",
12+
streamlit_script_path=panel_script_path,
13+
)
14+
panel.set_value("sample_string", "Hello, World #3!")
15+
panel.set_value("float_values", [1.1, 2.2, 3.3])
16+
17+
print(f"Panel URL: {panel.panel_url}")

examples/sample/sample_panel_2.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""Streamlit application script for displaying values using nipanel package."""
2+
3+
import streamlit as st
4+
5+
import nipanel
6+
7+
panel = nipanel.StreamlitPanelValueAccessor(panel_id="sample_panel_2")
8+
9+
st.title("Sample Panel Two")
10+
11+
col1, col2 = st.columns([0.4, 0.6])
12+
13+
with col1:
14+
st.write("String")
15+
st.write("Integer")
16+
17+
with col2:
18+
st.write(panel.get_value("sample_string"))
19+
st.write(panel.get_value("sample_int"))

examples/sample/sample_panel_3.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""Streamlit application script for displaying values using nipanel package."""
2+
3+
import streamlit as st
4+
5+
import nipanel
6+
7+
panel = nipanel.StreamlitPanelValueAccessor(panel_id="sample_panel_3")
8+
9+
st.title("Sample Panel Three")
10+
11+
col1, col2 = st.columns([0.4, 0.6])
12+
13+
with col1:
14+
st.write("String")
15+
st.write("List")
16+
17+
with col2:
18+
st.write(panel.get_value("sample_string"))
19+
st.write(panel.get_value("float_values"))

0 commit comments

Comments
 (0)