How can I assign a checkbox which has the behaviour of toggling enable/disabling another widget, in this case a number input?
param = st.number_input(
"Assign your parameter",
key=f"param",
disabled=False,)
param_lock = st.checkbox(
"Click to lock",
key=f"lock")
Is it possible to add an on_change arg to the button which then alters the number_input to disabled=True?
Or can anyone think of a work-around which might do this?
Here’s the simplest example I could think of:
import streamlit as st
# Store the value in session state (st.session_state.disable)
st.checkbox("Disable", value=False, key="disable")
num = st.number_input("Enter a number", disabled=st.session_state.disable)
1 Like
Thanks, that is perfect… overlooked that I could assign a value to the button!
1 Like
system
Closed
September 14, 2023, 2:13pm
5
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.