Skip to content

Commit 7db9fab

Browse files
author
Dilmi Wickramanayake
committed
created enum for channel source
1 parent 126dd92 commit 7db9fab

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

examples/niscope/niscope_configured_acquisition/niscope_configured_acquisition_panel.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Streamlit dashboard for visualizing NI-SCOPE waveform data in real time."""
22

3+
from enum import Enum
4+
35
import extra_streamlit_components as stx # type: ignore[import-untyped]
46
import niscope
57
import streamlit as st
@@ -8,6 +10,20 @@
810
import nipanel
911
from nipanel.controls import enum_selectbox
1012

13+
14+
class ChannelSource(Enum):
15+
"""Enum for channel source options."""
16+
17+
CHANNEL_0 = 0
18+
CHANNEL_1 = 1
19+
CHANNEL_2 = 2
20+
CHANNEL_3 = 3
21+
CHANNEL_4 = 4
22+
CHANNEL_5 = 5
23+
CHANNEL_6 = 6
24+
CHANNEL_7 = 7
25+
26+
1127
st.set_page_config(page_title="NI-SCOPE EX Configured Acquisition", page_icon="📈", layout="wide")
1228
st.title("NI-SCOPE EX Configured Acquisition")
1329
panel = nipanel.get_streamlit_panel_accessor()
@@ -206,12 +222,11 @@
206222
)
207223
if trigger_type == "2":
208224
with st.container(border=True):
209-
st.number_input(
225+
st.selectbox(
210226
"Trigger Source",
211-
value=0,
212-
step=1,
227+
options=list(ChannelSource),
228+
format_func=lambda x: f"Channel {x.value}",
213229
disabled=panel.get_value("is_running", False),
214-
max_value=7,
215230
key="edge_source",
216231
)
217232
st.number_input(
@@ -252,10 +267,10 @@
252267
)
253268
if trigger_type == "4":
254269
with st.container(border=True):
255-
st.number_input(
270+
st.selectbox(
256271
"Trigger Source",
257-
value=0,
258-
step=1,
272+
options=list(ChannelSource),
273+
format_func=lambda x: f"Channel {x.value}",
259274
disabled=panel.get_value("is_running", False),
260275
key="window_source",
261276
)
@@ -290,10 +305,10 @@
290305

291306
if trigger_type == "5":
292307
with st.container(border=True):
293-
st.number_input(
308+
st.selectbox(
294309
"Trigger Source",
295-
value=0,
296-
step=1,
310+
options=list(ChannelSource),
311+
format_func=lambda x: f"Channel {x.value}",
297312
disabled=panel.get_value("is_running", False),
298313
key="hysteresis_source",
299314
)

0 commit comments

Comments
 (0)