Incremeting progressbar

With st.progress we can set the value of a progressbar. But how can we increment it?


my_bar.progress(percent_complete + 1)  # Sets the progress bar to some value

but how can we instead increment the current value by something else? I tried

my_bar.progress(my_bar.value + 1) 

but that does not work.

You have to keep track of the “current value” somewhere else, usually in session_state.

st.session_state["counter"] = st.session_state.get("counter", 0)
bar = st.progress(st.session_state["counter"])
if st.button("Increment"):
    st.session_state["counter"] = min(100, st.session_state["counter"] + 5)