How to reset selectbox options after submitting

You can set (or reset) widgets by directly accessing their value via their key in session state.

import streamlit as st

st.selectbox('Select:',['Please Select',1,2,3],key='selection')

def reset():
    st.session_state.selection = 'Please Select'

st.button('Reset', on_click=reset)

I have a video about changing widgets through session state here: Session State Introduction

3 Likes