With st.progress we can set the value of a progressbar. But how can we increment it?
So
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.
Goyo
2
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)
system
Closed
3
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.