Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* changes * changes * add changeset * chagnes * chaneg * changes * fix * changes * changes --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
- Loading branch information
1 parent
649f3ce
commit 324867f
Showing
13 changed files
with
93 additions
and
79 deletions.
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,7 @@ | ||
--- | ||
"@gradio/app": patch | ||
"@gradio/client": patch | ||
"gradio": patch | ||
--- | ||
|
||
fix:Fix event target |
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: on_listener_basic"]}, {"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", "\n", "with gr.Blocks() as demo:\n", " name = gr.Textbox(label=\"Name\")\n", " output = gr.Textbox(label=\"Output Box\")\n", " greet_btn = gr.Button(\"Greet\")\n", "\n", " def greet(name):\n", " return \"Hello \" + name + \"!\"\n", "\n", " gr.on(\n", " triggers=[name.submit, greet_btn.click],\n", " fn=greet,\n", " inputs=name,\n", " outputs=output,\n", " )\n", "\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} | ||
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: on_listener_basic"]}, {"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", "\n", "with gr.Blocks() as demo:\n", " name = gr.Textbox(label=\"Name\")\n", " output = gr.Textbox(label=\"Output Box\")\n", " greet_btn = gr.Button(\"Greet\")\n", " trigger = gr.Textbox(label=\"Trigger Box\")\n", " trigger2 = gr.Textbox(label=\"Trigger Box\")\n", "\n", " def greet(name, evt_data: gr.EventData):\n", " return \"Hello \" + name + \"!\", evt_data.target.__class__.__name__\n", " \n", " def clear_name(evt_data: gr.EventData):\n", " return \"\", evt_data.target.__class__.__name__\n", " \n", " gr.on(\n", " triggers=[name.submit, greet_btn.click],\n", " fn=greet,\n", " inputs=name,\n", " outputs=[output, trigger],\n", " ).then(clear_name, outputs=[name, trigger2])\n", "\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "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
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: on_listener_test"]}, {"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", "\n", "with gr.Blocks() as demo:\n", " name = gr.Textbox(label=\"Name\")\n", " output = gr.Textbox(label=\"Output\")\n", " greet_btn = gr.Button(\"Greet\")\n", " trigger = gr.Textbox(label=\"Trigger 1\")\n", " trigger2 = gr.Textbox(label=\"Trigger 2\")\n", "\n", " def greet(name, evt_data: gr.EventData):\n", " return \"Hello \" + name + \"!\", evt_data.target.__class__.__name__\n", " \n", " def clear_name(evt_data: gr.EventData):\n", " return \"\", evt_data.target.__class__.__name__\n", " \n", " gr.on(\n", " triggers=[name.submit, greet_btn.click],\n", " fn=greet,\n", " inputs=name,\n", " outputs=[output, trigger],\n", " ).then(clear_name, outputs=[name, trigger2])\n", "\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "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,25 @@ | ||
import gradio as gr | ||
|
||
with gr.Blocks() as demo: | ||
name = gr.Textbox(label="Name") | ||
output = gr.Textbox(label="Output") | ||
greet_btn = gr.Button("Greet") | ||
trigger = gr.Textbox(label="Trigger 1") | ||
trigger2 = gr.Textbox(label="Trigger 2") | ||
|
||
def greet(name, evt_data: gr.EventData): | ||
return "Hello " + name + "!", evt_data.target.__class__.__name__ | ||
|
||
def clear_name(evt_data: gr.EventData): | ||
return "", evt_data.target.__class__.__name__ | ||
|
||
gr.on( | ||
triggers=[name.submit, greet_btn.click], | ||
fn=greet, | ||
inputs=name, | ||
outputs=[output, trigger], | ||
).then(clear_name, outputs=[name, trigger2]) | ||
|
||
|
||
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
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,22 @@ | ||
import { test, expect } from "@gradio/tootils"; | ||
|
||
test("On listener works.", async ({ page }) => { | ||
const name_box = await page.locator("textarea").nth(0); | ||
const output_box = await page.locator("textarea").nth(1); | ||
const trigger1_box = await page.locator("textarea").nth(2); | ||
const trigger2_box = await page.locator("textarea").nth(3); | ||
|
||
name_box.fill("Jimmy"); | ||
await page.click("text=Greet"); | ||
await expect(output_box).toHaveValue("Hello Jimmy!"); | ||
await expect(trigger1_box).toHaveValue("Button"); | ||
await expect(name_box).toHaveValue(""); | ||
await expect(trigger2_box).toHaveValue("Button"); | ||
|
||
await name_box.fill("Sally"); | ||
await name_box.press("Enter"); | ||
await expect(output_box).toHaveValue("Hello Sally!"); | ||
await expect(trigger1_box).toHaveValue("Textbox"); | ||
await expect(name_box).toHaveValue(""); | ||
await expect(trigger2_box).toHaveValue("Textbox"); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.