Created
November 22, 2022 02:46
-
-
Save treuille/427a7359c591adf4685110e34f3af4a9 to your computer and use it in GitHub Desktop.
Example of how to access widget state in a callback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To see this in action run: