import streamlit as st def _progress(): form_fields = st.session_state['form_fields'] return sum([bool(x) for x in form_fields.values()]) / len(form_fields) if 'form_fields' not in st.session_state: st.session_state['form_fields'] = { 'page_1_a': None, 'page_1_b': None, 'page_2_a': None, 'page_2_b': None } st.session_state['progress'] = _progress st.sidebar.progress(st.session_state['progress']()) st.sidebar.title("Test Multi-Page App") st.sidebar.markdown("""With streamlit 1.10.0, you can create [multipage apps](https://docs.streamlit.io/library/get-started/multipage-apps/create-a-multipage-app) right out of the box! 🎉 This simple demo uses that feature + Streamlit's [session state](https://docs.streamlit.io/library/advanced-features/session-state) to keep track of form fields across multiple pages, and report the global progress of filling out all the forms. This sort of workflow used to take a lot more effort, so it's cool to see it working a bit smoother now. 🤗 """) "Here's the dict containing all the form field values for the current session:" st.json(st.session_state['form_fields'])