Created
April 19, 2022 13:54
-
-
Save asehmi/34cdfe55077ee7ca5a4391ee69b4cb76 to your computer and use it in GitHub Desktop.
A simple Streamlit Pomodoro count down timer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Author
asehmi
commented
Apr 19, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment