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.
example:

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

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).

HTH,
Arvindra

1 Like

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

1 Like