The main issue is that after disabling certain input and buttons using session state, I’m unable to re-enable them effectively.
streamlit : 1.37
Expected Behavior:
After calling the enable()
function, which sets st.session_state.disabled
to False
, all previously disabled inputs should become active and interactive, allowing user interaction as normal.
As long as the fitting process is running, all inputs and buttons will be disabled.
Observed Behavior:
Even after setting st.session_state.disabled
back to False
, the inputs remain disabled, preventing further user interaction.
import streamlit as st
if 'disabled' not in st.session_state:
st.session_state.disabled = False
def disable():
st.session_state.disabled = True
# User input for the ticker symbol
user_ticker_input = st.text_input(
"Enter a ticker",
disabled=st.session_state.disabled,
).upper()
# Trigger fitting process
if st.button("Predict", on_click=disable, disabled=st.session_state.disabled):
# Fit the model and make predictions
# Model fitting code here...
# Re-enable interactions after prediction
st.session_state.disabled = False