I need a functionality:
- There is a button which is on by default
- When user input is give, the button is disabled for time untile the input is being processed.
- Button is enabled again after is processing is completed.
import streamlit as st
import time
def expensive_process():
with st.spinner('Processing...'):
time.sleep(2)
if 'run' not in st.session_state:
st.session_state.run = False
lock = st.session_state.run
st.button('Run', disabled=lock)
input = st.chat_input("Enter")
if input:
st.session_state.run = True # Button is disabled as the input as to be processed
st.session_state.result = expensive_process()
st.session_state.run = False # Button is enabled again