Spaces:
Sleeping
Sleeping
File size: 822 Bytes
094ed21 0a06956 74b393a 094ed21 9424dae 094ed21 0a06956 094ed21 0a06956 094ed21 9424dae 094ed21 0a06956 094ed21 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import gradio as gr
import time
# Timer function
def start_timer(seconds):
# Countdown loop
for remaining in range(seconds, 0, -1):
time.sleep(1) # Wait for 1 second
yield f"{remaining} seconds remaining..."
return "Time's up!"
# Create Gradio interface
with gr.Blocks() as demo:
gr.Markdown("## Timer App") # Display the header for the page
with gr.Row():
time_input = gr.Slider(minimum=1, maximum=600, step=1, label="Set Timer (seconds)")
start_button = gr.Button("Start Timer") # Button to start timer
timer_output = gr.Textbox(label="Timer Output", interactive=False)
# Connect the button with the timer function
start_button.click(start_timer, inputs=time_input, outputs=timer_output)
# Launch the Gradio interface
demo.launch() |