-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docs for
.on()
, .then()
, and .success()
, as well as the sub…
…classes of `gr.EventData` (#8604) * more helpers * add changeset * add changeset * lint * trigger list * add example * docstring * dependency * add changeset * events * document subclasses * fix syntax * event data svx * add changeset * selectdata * lint * key up data * 2 more * on * other placeholders * lint * address reviews * tweak * Update js/_website/src/lib/templates/gradio/04_helpers/01_eventdata.svx Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com> --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>
- Loading branch information
1 parent
8d425ee
commit b6fa6b5
Showing
11 changed files
with
634 additions
and
45 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,6 @@ | ||
--- | ||
"gradio": patch | ||
"website": patch | ||
--- | ||
|
||
feat:Add docs for `.on()`, `.then()`, and `.success()`, as well as the subclasses of `gr.EventData` |
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
73 changes: 73 additions & 0 deletions
73
js/_website/src/lib/templates/gradio/04_helpers/01_eventdata.svx
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,73 @@ | ||
|
||
<script lang="ts"> | ||
import {get_object} from "../../process_json.ts"; | ||
import ParamTable from "$lib/components/ParamTable.svelte"; | ||
import ShortcutTable from "$lib/components/ShortcutTable.svelte"; | ||
import DemosSection from "$lib/components/DemosSection.svelte"; | ||
import FunctionsSection from "$lib/components/FunctionsSection.svelte"; | ||
import GuidesSection from "$lib/components/GuidesSection.svelte"; | ||
import CopyButton from "$lib/components/CopyButton.svelte"; | ||
import { style_formatted_text } from "$lib/text"; | ||
|
||
let obj = get_object("eventdata"); | ||
obj.parameters[0]["kwargs"] = null; | ||
</script> | ||
|
||
<!--- Title --> | ||
# {obj.name} | ||
|
||
<!--- Usage --> | ||
```python | ||
gradio.EventData(···) | ||
``` | ||
|
||
<!--- Description --> | ||
### Description | ||
## {@html style_formatted_text(obj.description)} | ||
|
||
<!-- Example Usage --> | ||
|
||
{#if obj.example} | ||
### Example Usage | ||
```python | ||
import gradio as gr | ||
|
||
with gr.Blocks() as demo: | ||
table = gr.Dataframe([[1, 2, 3], [4, 5, 6]]) | ||
gallery = gr.Gallery([("cat.jpg", "Cat"), ("dog.jpg", "Dog")]) | ||
textbox = gr.Textbox("Hello World!") | ||
statement = gr.Textbox() | ||
|
||
def on_select(value, evt: gr.EventData): | ||
return f"The {evt.target} component was selected, and its value was {value}." | ||
|
||
table.select(on_select, table, statement) | ||
gallery.select(on_select, gallery, statement) | ||
textbox.select(on_select, textbox, statement) | ||
|
||
demo.launch() | ||
``` | ||
{/if} | ||
|
||
<!--- Initialization --> | ||
### Attributes | ||
<ParamTable parameters={obj.parameters} /> | ||
|
||
|
||
{#if obj.demos && obj.demos.length > 0} | ||
<!--- Demos --> | ||
### Demos | ||
<DemosSection demos={obj.demos} /> | ||
{/if} | ||
|
||
{#if obj.fns && obj.fns.length > 0} | ||
<!--- Methods --> | ||
### Methods | ||
<FunctionsSection fns={obj.fns} event_listeners={false} /> | ||
{/if} | ||
|
||
{#if obj.guides && obj.guides.length > 0} | ||
<!--- Guides --> | ||
### Guides | ||
<GuidesSection guides={obj.guides}/> | ||
{/if} |
Oops, something went wrong.