Skip to content

Commit dd9d95b

Browse files
author
Dilmi Wickramanayake
committed
disable run button
1 parent da485d6 commit dd9d95b

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

examples/nidaqmx/nidaqmx_analog_output_voltage/nidaqmx_analog_output_voltage.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@
2323
available_channel_names.append(chan.name)
2424
panel.set_value("available_channel_names", available_channel_names)
2525

26-
available_trigger_sources = []
26+
available_trigger_sources = [""]
2727
for dev in system.devices:
2828
if hasattr(dev, "terminals"):
2929
for term in dev.terminals:
3030
available_trigger_sources.append(term)
3131
panel.set_value("available_trigger_sources", available_trigger_sources)
3232
try:
33+
panel.set_value("daq_error", "")
3334
print(f"Panel URL: {panel.panel_url}")
3435
print(f"Waiting for the 'Run' button to be pressed...")
3536
print(f"(Press Ctrl + C to quit)")
@@ -51,7 +52,7 @@
5152
amplitude = panel.get_value("amplitude", 1.0)
5253

5354
task.timing.cfg_samp_clk_timing(
54-
source=panel.get_value("source", "/Dev4/PFI0"),
55+
source=panel.get_value("source", ""), # "" - OnboardClock
5556
rate=sample_rate,
5657
sample_mode=AcquisitionType.CONTINUOUS,
5758
)
@@ -82,7 +83,6 @@
8283
writer.write_many_sample(waveform)
8384
panel.set_value("data", waveform.tolist())
8485
try:
85-
panel.set_value("daq_error", "")
8686
task.start()
8787
panel.set_value("is_running", True)
8888
panel.set_value("stop_button", False)

examples/nidaqmx/nidaqmx_analog_output_voltage/nidaqmx_analog_output_voltage_panel.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@
3535
unsafe_allow_html=True,
3636
)
3737

38+
39+
def hide_run_button()-> None:
40+
"""hide_run_button is used to disable run button when DAQ error pops up."""
41+
st.markdown(
42+
"""
43+
<style>
44+
button[data-testid="stBaseButton-secondary"] {
45+
display: none;
46+
}
47+
</style>
48+
""",
49+
unsafe_allow_html=True,
50+
)
51+
52+
3853
with left_col:
3954
with st.container(border=True):
4055
is_running = panel.get_value("is_running", True)
@@ -46,7 +61,8 @@
4661
if panel.get_value("daq_error", "") == "":
4762
pass
4863
else:
49-
st.error(panel.get_value("daq_error", ""))
64+
hide_run_button()
65+
st.error(panel.get_value("daq_error", "") + " Please re-run script")
5066

5167
st.title("Channel Settings")
5268
physical_channel = st.selectbox(

0 commit comments

Comments
 (0)