-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
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
Add Timer component #8505
Merged
Merged
Add Timer component #8505
Changes from all commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
be480a4
chagnes
486c20e
add changeset
gradio-pr-bot 9b04005
changes
c204ab0
changes
53af29d
Merge branch 'timer_event_listener' of https://github.com/gradio-app/…
d5dc03e
changes
4d0a537
Merge remote-tracking branch 'origin' into timer_event_listener
789fba8
Merge remote-tracking branch 'origin' into timer_event_listener
cb9fd09
changes
05924ef
Merge remote-tracking branch 'origin' into timer_event_listener
3a69f74
changes
f4f2f15
Merge remote-tracking branch 'origin' into timer_event_listener
3d641da
changes
54f025d
changes
0d69e96
changes
8b74afa
changes
0af8d6d
changes
023a246
changes
bde393b
changes
eec6f35
changes
742112a
Merge remote-tracking branch 'origin' into timer_event_listener
a2e0bdf
changes
e5bf2fe
Merge branch 'main' into timer_event_listener
aliabid94 398f92c
change
47b3905
add docs
aliabd 187e717
add changeset
gradio-pr-bot e89ddca
remove demo
aliabd 376db8f
Merge branch 'timer_event_listener' of https://github.com/gradio-app/…
aliabd eef0b53
Merge branch 'main' into timer_event_listener
pngwn 2031e82
Merge branch 'main' into timer_event_listener
aliabd 1404e52
Merge branch 'main' into timer_event_listener
abidlabs c778af5
add changeset
gradio-pr-bot f94b60e
changes
cf9d69a
add changeset
gradio-pr-bot cf7828a
changes
53b4222
changes
6915705
changes
5fa2dbb
add changeset
gradio-pr-bot bcf3dca
Merge remote-tracking branch 'origin' into timer_event_listener
d0655dd
Merge branch 'timer_event_listener' of https://github.com/gradio-app/…
9a7072e
changes
7872a20
changes
945806d
changes
be99ccb
changes
a4de90f
changes
21c3479
changes
1bd6546
changes
6a27dc3
changes
90173bf
changes
7930ee1
Update gradio/components/timer.py
aliabid94 115e7c7
Merge branch 'main' into timer_event_listener
abidlabs d8db005
changes
171f085
Merge remote-tracking branch 'origin' into timer_event_listener
de843f3
changes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
"@gradio/app": minor | ||
"@gradio/client": minor | ||
"@gradio/timer": minor | ||
"gradio": minor | ||
"gradio_client": minor | ||
"website": minor | ||
--- | ||
|
||
fix:Add Timer component |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: function_values"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import random\n", "\n", "countries = [\n", " \"Algeria\", \"Argentina\", \"Australia\", \"Brazil\", \"Canada\", \"China\", \"Democratic Republic of the Congo\", \"Greenland (Denmark)\", \"India\", \"Kazakhstan\", \"Mexico\", \"Mongolia\", \"Peru\", \"Russia\", \"Saudi Arabia\", \"Sudan\", \"United States\"\n", "]\n", "\n", "with gr.Blocks() as demo:\n", " with gr.Row():\n", " count = gr.Slider(1, 10, step=1, label=\"Country Count\")\n", " alpha_order = gr.Checkbox(True, label=\"Alphabetical Order\")\n", "\n", " gr.JSON(lambda count, alpha_order: countries[:count] if alpha_order else countries[-count:], inputs=[count, alpha_order])\n", " timer = gr.Timer(1)\n", " with gr.Row():\n", " gr.Textbox(lambda: random.choice(countries), label=\"Random Country\", every=timer)\n", " gr.Textbox(lambda count: \", \".join(random.sample(countries, count)), inputs=count, label=\"Random Countries\", every=timer)\n", " with gr.Row():\n", " gr.Button(\"Start\").click(lambda: gr.Timer(active=True), None, timer)\n", " gr.Button(\"Stop\").click(lambda: gr.Timer(active=False), None, timer)\n", "\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import gradio as gr | ||
import random | ||
|
||
countries = [ | ||
"Algeria", "Argentina", "Australia", "Brazil", "Canada", "China", "Democratic Republic of the Congo", "Greenland (Denmark)", "India", "Kazakhstan", "Mexico", "Mongolia", "Peru", "Russia", "Saudi Arabia", "Sudan", "United States" | ||
] | ||
|
||
with gr.Blocks() as demo: | ||
with gr.Row(): | ||
count = gr.Slider(1, 10, step=1, label="Country Count") | ||
alpha_order = gr.Checkbox(True, label="Alphabetical Order") | ||
|
||
gr.JSON(lambda count, alpha_order: countries[:count] if alpha_order else countries[-count:], inputs=[count, alpha_order]) | ||
timer = gr.Timer(1) | ||
with gr.Row(): | ||
gr.Textbox(lambda: random.choice(countries), label="Random Country", every=timer) | ||
gr.Textbox(lambda count: ", ".join(random.sample(countries, count)), inputs=count, label="Random Countries", every=timer) | ||
with gr.Row(): | ||
gr.Button("Start").click(lambda: gr.Timer(active=True), None, timer) | ||
gr.Button("Stop").click(lambda: gr.Timer(active=False), None, timer) | ||
|
||
|
||
if __name__ == "__main__": | ||
demo.launch() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: timer"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import random\n", "import time\n", "\n", "with gr.Blocks() as demo:\n", " timer = gr.Timer(1)\n", " timestamp = gr.Number(label=\"Time\")\n", " timer.tick(lambda: round(time.time()), outputs=timestamp)\n", " gr.Number(lambda: round(time.time()), label=\"Time 2\", every=1)\n", "\n", " with gr.Row():\n", " timestamp_3 = gr.Number()\n", " start_btn = gr.Button(\"Start\")\n", " stop_btn = gr.Button(\"Stop\")\n", "\n", " time_3 = start_btn.click(lambda: round(time.time()), None, timestamp_3, every=1)\n", " stop_btn.click(fn=None, cancels=time_3)\n", "\n", " with gr.Row():\n", " min = gr.Number(1, label=\"Min\")\n", " max = gr.Number(10, label=\"Max\")\n", " timer2 = gr.Timer(1)\n", " number = gr.Number(lambda a, b: random.randint(a, b), inputs=[min, max], every=timer2, label=\"Random Number\")\n", " with gr.Row():\n", " gr.Button(\"Start\").click(lambda: gr.Timer(active=True), None, timer2)\n", " gr.Button(\"Stop\").click(lambda: gr.Timer(active=False), None, timer2)\n", " gr.Button(\"Go Fast\").click(lambda: 0.2, None, timer2)\n", " gr.Button(\"Go Slow\").click(lambda: 2, None, timer2)\n", " \n", "if __name__ == \"__main__\":\n", " demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
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() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ | |
State, | ||
Text, | ||
Textbox, | ||
Timer, | ||
UploadButton, | ||
Video, | ||
component, | ||
|
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we still need this when the Client connects to Spaces running older versions of Gradio?