Skip to content

Instantly share code, notes, and snippets.

View treuille's full-sized avatar

Adrien Treuille treuille

View GitHub Profile
@treuille
treuille / streamlit_app.py
Created November 22, 2022 02:46
Example of how to access widget state in a callback.
import streamlit as st
with st.echo():
def on_change():
st.write(f"my_selection **(1)**: `{st.session_state.my_selection}`")
my_selection = st.selectbox(
"Select something", ["a", "b"], on_change=on_change, key="my_selection"
)
st.write(f"my_selection **(2)**: `{st.session_state.my_selection}`")