Skip to content

Instantly share code, notes, and snippets.

@FerusAndBeyond
Last active April 19, 2022 19:33
Show Gist options
  • Save FerusAndBeyond/9440dc40ebf5f419bb10e71f448a3eba to your computer and use it in GitHub Desktop.
Save FerusAndBeyond/9440dc40ebf5f419bb10e71f448a3eba to your computer and use it in GitHub Desktop.
import streamlit as st
# initialize the "count"-variable to session state
if "count" not in st.session_state:
st.session_state["count"] = 0
# clicked will be True when the button was clicked
# and False otherwise (for example if another action
# was performed or if it has not been clicked yet)
clicked = st.button("Click here!")
# Adding true is the same as adding 1
# Adding False is the same as adding 0
st.session_state["count"] += clicked
# Show the count
st.text(f"Count is {st.session_state['count']}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment