Creating a stopwatch timer on button click until its True

I’m looking to display a stopwatch-timer running (dynamic with each sec updating) when the button is clicked until its True.

if my_button:
    st.write(<timer starts>)

This is (almost) the solution you want. It’s not as simple as you have imagined because you need to get an async operation working in collaboration with Streamlit’s rerun mechanics. You’ll need to modify the while loop condition to allow the watch to be stopped and started (i.e., a stopwatch).


1 Like

It did seem not so easy
Thanks for the thread, this should workout hopefully!

1 Like