Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions examples/all_types/all_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
panel_script_path = Path(__file__).with_name("all_types_panel.py")
panel = nipanel.create_streamlit_panel(panel_script_path)

panel.set_value("example_selectbox", "Option 1")
panel.set_value("example_slider", 50)
panel.set_value("example_color_picker", "#000000")
panel.set_value("example_multiselect", ["Option 1"])
panel.set_value("example_radio", "Option 1")

print("Setting values")
for name, value in all_types_with_values.items():
print(f"{name:>15} {value}")
Expand All @@ -20,4 +26,5 @@
the_value = panel.get_value(name)
print(f"{name:>20} {the_value}")


print(f"Panel URL: {panel.panel_url}")
87 changes: 86 additions & 1 deletion examples/all_types/all_types_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,97 @@
st.title("All Types Example")

panel = nipanel.get_streamlit_panel_accessor()

col1, col2, col3 = st.columns([0.2, 0.2, 0.6])
with col1:
st.header("Control or Type")
with col2:
st.header("Input")
with col3:
st.header("Output")

st.markdown("---")
col1, col2, col3 = st.columns([0.2, 0.2, 0.6])
with col1:
st.write("st.selectbox")
with col2:
st.selectbox(
label="string",
options=["Option 1", "Option 2", "Option 3", "Option 4"],
key="example_selectbox",
)
with col3:
st.write(panel.get_value("example_selectbox", ""))

st.markdown("---")
col1, col2, col3 = st.columns([0.2, 0.2, 0.6])
with col1:
st.write("st.slider & st.progress")
with col2:
st.slider(
label="int",
min_value=0,
max_value=100,
value=50,
key="example_slider",
)
with col3:
progress = panel.get_value("example_slider", 50)
st.progress(progress / 100, text=f"{progress}%")


st.markdown("---")
col1, col2, col3 = st.columns([0.2, 0.2, 0.6])
with col1:
st.write("st.color_picker")
with col2:
st.color_picker(
label="color",
value="#000000",
key="example_color_picker",
)
with col3:
color = panel.get_value("example_color_picker", "#000000")
st.write(color)
st.markdown(
f"<div style='width:40px; height:20px; background:{color}; border:1px solid #888;'></div>",
unsafe_allow_html=True,
)

st.markdown("---")
col1, col2, col3 = st.columns([0.2, 0.2, 0.6])
with col1:
st.write("st.multiselect")
with col2:
st.multiselect(
label="list of strings",
options=["Option A", "Option B", "Option C", "Option D"],
default=["Option A"],
key="example_multiselect",
)
with col3:
st.write(panel.get_value("example_multiselect", ["Option A"]))

st.markdown("---")
col1, col2, col3 = st.columns([0.2, 0.2, 0.6])
with col1:
st.write("st.radio")
with col2:
st.radio(
label="string",
options=["Choice 1", "Choice 2", "Choice 3"],
index=0,
key="example_radio",
)
with col3:
st.write(panel.get_value("example_radio", "Choice 1"))

for name in all_types_with_values.keys():
st.markdown("---")

default_value = all_types_with_values[name]
col1, col2, col3 = st.columns([0.2, 0.2, 0.6])

col1, col2, col3 = st.columns([0.2, 0.2, 0.6])
with col1:
st.write(name)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@
f"There was an error running the script. Fix the issue and re-run nidaqmx_analog_input_filtering.py \n\n {panel.get_value('daq_error', '')}"
)
st.title("Channel Settings")
physical_channel = st.selectbox(
st.selectbox(
options=panel.get_value("available_channel_names", ["Mod2/ai0"]),
index=0,
label="Physical Channels",
disabled=panel.get_value("is_running", False),
key="physical_channel",
)
panel.set_value("physical_channel", physical_channel)
enum_selectbox(
panel,
label="Terminal Configuration",
Expand All @@ -74,13 +74,13 @@

st.title("Timing Settings")

source = st.selectbox(
st.selectbox(
"Sample Clock Source",
options=panel.get_value("available_trigger_sources", [""]),
index=0,
disabled=panel.get_value("is_running", False),
key="source",
)
panel.set_value("source", source)
st.number_input(
"Sample Rate",
value=1000.0,
Expand All @@ -106,12 +106,12 @@
)
st.title("Filtering Settings")

filter = st.selectbox(
st.selectbox(
"Filter",
options=["No Filtering", "Filter"],
disabled=panel.get_value("is_running", False),
key="filter",
)
panel.set_value("filter", filter)
enum_selectbox(
panel,
label="Filter Response",
Expand Down Expand Up @@ -203,10 +203,11 @@
)
if trigger_type == "2":
with st.container(border=True):
source = st.selectbox(
"Source", options=panel.get_value("available_trigger_sources", [""])
st.selectbox(
"Source",
options=panel.get_value("available_trigger_sources", [""]),
key="digital_source",
)
panel.set_value("digital_source", source)
enum_selectbox(
panel,
label="Edge",
Expand Down