Skip to content

Commit 48f5626

Browse files
author
Dilmi Wickramanayake
committed
Merge branch 'users/DilmiWickramanayake/niscope_binary' of https://github.com/ni/nipanel-python into users/DilmiWickramanayake/niscope_binary
2 parents d56a096 + 7e85c89 commit 48f5626

File tree

12 files changed

+486
-324
lines changed

12 files changed

+486
-324
lines changed

.github/renovate.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"local>ni/python-renovate-config:recommended"
5+
]
6+
}

.github/renovate.json5

Lines changed: 0 additions & 41 deletions
This file was deleted.

examples/all_types/all_types.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
panel_script_path = Path(__file__).with_name("all_types_panel.py")
1010
panel = nipanel.create_streamlit_panel(panel_script_path)
1111

12+
panel.set_value("example_selectbox", "Option 1")
13+
panel.set_value("example_slider", 50)
14+
panel.set_value("example_color_picker", "#000000")
15+
panel.set_value("example_multiselect", ["Option 1"])
16+
panel.set_value("example_radio", "Option 1")
17+
1218
print("Setting values")
1319
for name, value in all_types_with_values.items():
1420
print(f"{name:>15} {value}")
@@ -20,4 +26,5 @@
2026
the_value = panel.get_value(name)
2127
print(f"{name:>20} {the_value}")
2228

29+
2330
print(f"Panel URL: {panel.panel_url}")

examples/all_types/all_types_panel.py

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""A Streamlit visualization panel for the all_types.py example script."""
22

3+
import datetime as dt
34
from enum import Enum, Flag
45

56
import streamlit as st
@@ -13,12 +14,97 @@
1314
st.title("All Types Example")
1415

1516
panel = nipanel.get_streamlit_panel_accessor()
17+
18+
col1, col2, col3 = st.columns([0.2, 0.2, 0.6])
19+
with col1:
20+
st.header("Control or Type")
21+
with col2:
22+
st.header("Input")
23+
with col3:
24+
st.header("Output")
25+
26+
st.markdown("---")
27+
col1, col2, col3 = st.columns([0.2, 0.2, 0.6])
28+
with col1:
29+
st.write("st.selectbox")
30+
with col2:
31+
st.selectbox(
32+
label="string",
33+
options=["Option 1", "Option 2", "Option 3", "Option 4"],
34+
key="example_selectbox",
35+
)
36+
with col3:
37+
st.write(panel.get_value("example_selectbox", ""))
38+
39+
st.markdown("---")
40+
col1, col2, col3 = st.columns([0.2, 0.2, 0.6])
41+
with col1:
42+
st.write("st.slider & st.progress")
43+
with col2:
44+
st.slider(
45+
label="int",
46+
min_value=0,
47+
max_value=100,
48+
value=50,
49+
key="example_slider",
50+
)
51+
with col3:
52+
progress = panel.get_value("example_slider", 50)
53+
st.progress(progress / 100, text=f"{progress}%")
54+
55+
56+
st.markdown("---")
57+
col1, col2, col3 = st.columns([0.2, 0.2, 0.6])
58+
with col1:
59+
st.write("st.color_picker")
60+
with col2:
61+
st.color_picker(
62+
label="color",
63+
value="#000000",
64+
key="example_color_picker",
65+
)
66+
with col3:
67+
color = panel.get_value("example_color_picker", "#000000")
68+
st.write(color)
69+
st.markdown(
70+
f"<div style='width:40px; height:20px; background:{color}; border:1px solid #888;'></div>",
71+
unsafe_allow_html=True,
72+
)
73+
74+
st.markdown("---")
75+
col1, col2, col3 = st.columns([0.2, 0.2, 0.6])
76+
with col1:
77+
st.write("st.multiselect")
78+
with col2:
79+
st.multiselect(
80+
label="list of strings",
81+
options=["Option A", "Option B", "Option C", "Option D"],
82+
default=["Option A"],
83+
key="example_multiselect",
84+
)
85+
with col3:
86+
st.write(panel.get_value("example_multiselect", ["Option A"]))
87+
88+
st.markdown("---")
89+
col1, col2, col3 = st.columns([0.2, 0.2, 0.6])
90+
with col1:
91+
st.write("st.radio")
92+
with col2:
93+
st.radio(
94+
label="string",
95+
options=["Choice 1", "Choice 2", "Choice 3"],
96+
index=0,
97+
key="example_radio",
98+
)
99+
with col3:
100+
st.write(panel.get_value("example_radio", "Choice 1"))
101+
16102
for name in all_types_with_values.keys():
17103
st.markdown("---")
18104

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

107+
col1, col2, col3 = st.columns([0.2, 0.2, 0.6])
22108
with col1:
23109
st.write(name)
24110

@@ -35,6 +121,11 @@
35121
st.number_input(label=name, value=default_value, key=name, format="%.2f")
36122
elif isinstance(default_value, str):
37123
st.text_input(label=name, value=default_value, key=name)
124+
elif isinstance(default_value, dt.datetime):
125+
date = st.date_input(label="date", value=default_value)
126+
time = st.time_input(label="time", value=default_value)
127+
datetime = dt.datetime.combine(date, time)
128+
panel.set_value(name, datetime)
38129

39130
with col3:
40131
st.write(panel.get_value(name, default_value=default_value))

examples/all_types/define_types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Define types."""
22

3+
import datetime as dt
34
import enum
45

56
import numpy as np
@@ -70,6 +71,7 @@ class MyMixedEnum(enum.Enum):
7071
"float": 13.12,
7172
"int": 42,
7273
"str": "sample string",
74+
"dt_datetime": dt.datetime.now(),
7375
# supported enum and flag types
7476
"intflags": MyIntFlags.VALUE1 | MyIntFlags.VALUE4,
7577
"intenum": MyIntEnum.VALUE20,

examples/nidaqmx/nidaqmx_analog_input_filtering/nidaqmx_analog_input_filtering_panel.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@
5757
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', '')}"
5858
)
5959
st.title("Channel Settings")
60-
physical_channel = st.selectbox(
60+
st.selectbox(
6161
options=panel.get_value("available_channel_names", ["Mod2/ai0"]),
6262
index=0,
6363
label="Physical Channels",
6464
disabled=panel.get_value("is_running", False),
65+
key="physical_channel",
6566
)
66-
panel.set_value("physical_channel", physical_channel)
6767
enum_selectbox(
6868
panel,
6969
label="Terminal Configuration",
@@ -74,13 +74,13 @@
7474

7575
st.title("Timing Settings")
7676

77-
source = st.selectbox(
77+
st.selectbox(
7878
"Sample Clock Source",
7979
options=panel.get_value("available_trigger_sources", [""]),
8080
index=0,
8181
disabled=panel.get_value("is_running", False),
82+
key="source",
8283
)
83-
panel.set_value("source", source)
8484
st.number_input(
8585
"Sample Rate",
8686
value=1000.0,
@@ -106,12 +106,12 @@
106106
)
107107
st.title("Filtering Settings")
108108

109-
filter = st.selectbox(
109+
st.selectbox(
110110
"Filter",
111111
options=["No Filtering", "Filter"],
112112
disabled=panel.get_value("is_running", False),
113+
key="filter",
113114
)
114-
panel.set_value("filter", filter)
115115
enum_selectbox(
116116
panel,
117117
label="Filter Response",
@@ -203,10 +203,11 @@
203203
)
204204
if trigger_type == "2":
205205
with st.container(border=True):
206-
source = st.selectbox(
207-
"Source", options=panel.get_value("available_trigger_sources", [""])
206+
st.selectbox(
207+
"Source",
208+
options=panel.get_value("available_trigger_sources", [""]),
209+
key="digital_source",
208210
)
209-
panel.set_value("digital_source", source)
210211
enum_selectbox(
211212
panel,
212213
label="Edge",

0 commit comments

Comments
 (0)