adf0d17497
publish / version_or_publish (push) Has been cancelled
storybook-build / changes (push) Has been cancelled
storybook-build / :storybook-build (push) Has been cancelled
Sync Gradio Skills to Hugging Face / sync-skills (push) Has been cancelled
functional / changes (push) Has been cancelled
functional / build-frontend (push) Has been cancelled
functional / functional-test-SSR=false (push) Has been cancelled
functional / functional-reload (push) Has been cancelled
js / changes (push) Has been cancelled
js / js-test (push) Has been cancelled
docs-build / changes (push) Has been cancelled
docs-build / docs-build (push) Has been cancelled
docs-build / website-build (push) Has been cancelled
functional / functional-test-SSR=true (push) Has been cancelled
hygiene / hygiene-test (push) Has been cancelled
python / changes (push) Has been cancelled
python / build (push) Has been cancelled
python / test-ubuntu-latest-flaky (push) Has been cancelled
python / test-ubuntu-latest-not-flaky (push) Has been cancelled
python / test-windows-latest-flaky (push) Has been cancelled
python / test-windows-latest-not-flaky (push) Has been cancelled
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
import gradio as gr
|
|
import random
|
|
import time
|
|
|
|
with gr.Blocks() as demo:
|
|
timer = gr.Timer(1)
|
|
timestamp = gr.Number(label="Time")
|
|
timer.tick(lambda: round(time.time()), outputs=timestamp)
|
|
gr.Number(lambda: round(time.time()), label="Time 2", every=1)
|
|
|
|
with gr.Row():
|
|
timestamp_3 = gr.Number()
|
|
start_btn = gr.Button("Start")
|
|
stop_btn = gr.Button("Stop")
|
|
|
|
time_3 = start_btn.click(lambda: round(time.time()), None, timestamp_3, every=1)
|
|
stop_btn.click(fn=None, cancels=time_3)
|
|
|
|
with gr.Row():
|
|
min = gr.Number(1, label="Min")
|
|
max = gr.Number(10, label="Max")
|
|
timer2 = gr.Timer(1)
|
|
number = gr.Number(lambda a, b: random.randint(a, b), inputs=[min, max], every=timer2, label="Random Number")
|
|
with gr.Row():
|
|
gr.Button("Start").click(lambda: gr.Timer(active=True), None, timer2)
|
|
gr.Button("Stop").click(lambda: gr.Timer(active=False), None, timer2)
|
|
gr.Button("Go Fast").click(lambda: 0.2, None, timer2)
|
|
gr.Button("Go Slow").click(lambda: 2, None, timer2)
|
|
|
|
if __name__ == "__main__":
|
|
demo.launch()
|