Summary
I have a form on the sidebar with 1. upload file widget 2. submit button saying ‘process uploaded files’.
I understand how to disable the submit button but I also want to disable the upload file widget.
How would I do this?
Steps to reproduce
Code snippet:
if 'disabled' not in st.session_state:
st.session_state.disabled = False
def disable():
st.session_state.disabled = True
st.sidebar.title('File Upload and Processing')
with st.sidebar.form(key='sidebar_form'):
# Allow the user to upload a file
uploaded_file = st.file_uploader("Upload a file", type=["pdf", "txt"], key='file_upload_widget')
# If a file was uploaded, display its contents
if uploaded_file is not None:
if save_files(uploaded_file):
st.subheader('Uploaded files')
st.success(f'files uploaded {st.session_state.uploaded_files}')
submit_btn = st.form_submit_button('Process Uploaded Files',
on_click=disable,
disabled=st.session_state.disabled)
if submit_btn:
st.sidebar.write('No more upload possible')
Desired behavior:
This disabled the submit button but what I want to disable (additional to submit button is the upload file section so that user cannot upload any more files