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

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.