I use the both the
text_input widgets for getting the user input.
The user can input it’s own text (via the
text_input) or choose an existing sample (from the
Let’s say the user has chosen the
text01 option from the
selectbox, and then manually inputted his own text (meanwhile his first choice of
text01 still appears at the
selectbox. How can, how can I “reset” it’s display to the first option (
"" in this case)?
import streamlit as st if __name__ == '__main__': input_slot = st.empty() st.write("select an example sentence") selected = st.selectbox("select", ["", "aaa","bbb","ccc"]) val = input_slot.text_input("input", value=selected) st.write(val) # if user inputted manual text: # reset selectbox to DEFAULT option