We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reported at https://discuss.streamlit.io/t/new-library-stlite-a-port-of-streamlit-to-wasm-powered-by-pyodide/25556/3
The source code copied:
import streamlit as st import time st.set_page_config( page_title='Pomodoro', layout='centered', page_icon='🍅' ) def count_down(ts): with st.empty(): while True: mins, secs = divmod(ts, 60) time_now = '{:02d}:{:02d}'.format(mins, secs) st.header(f"{time_now}") time.sleep(1) ts -= 1 if ts < 0: break st.write("Time Up!") st.balloons() def main(): st.title("Pomodoro") time_minutes = st.number_input('Enter the time in minutes ', min_value=0.1, value=25.0) time_in_seconds = time_minutes * 60 if st.button("START"): count_down(int(time_in_seconds)) if __name__ == '__main__': main()
The text was updated successfully, but these errors were encountered:
time.sleep() is noop in Pyodide runtime. pyodide/pyodide#2354
time.sleep()
Sorry, something went wrong.
With a support of top-level await since (#514 ), we now can use asyncio.sleep() instead of time.sleep(), so the following code works.
asyncio.sleep()
import asyncio import time import streamlit as st st.set_page_config( page_title='Pomodoro', layout='centered', page_icon='🍅' ) async def count_down(ts): with st.empty(): while True: mins, secs = divmod(ts, 60) time_now = '{:02d}:{:02d}'.format(mins, secs) st.header(f"{time_now}") await asyncio.sleep(1) ts -= 1 if ts < 0: break st.write("Time Up!") st.balloons() async def main(): st.title("Pomodoro") time_minutes = st.number_input('Enter the time in minutes ', min_value=0.1, value=25.0) time_in_seconds = time_minutes * 60 if st.button("START"): await count_down(int(time_in_seconds)) if __name__ == '__main__': await main()
No branches or pull requests
Reported at https://discuss.streamlit.io/t/new-library-stlite-a-port-of-streamlit-to-wasm-powered-by-pyodide/25556/3
The source code copied:
The text was updated successfully, but these errors were encountered: