text stringlengths 0 2k | heading1 stringlengths 3 79 | source_page_url stringclasses 189
values | source_page_title stringclasses 189
values |
|---|---|---|---|
open delimiter (str), "right": close
delimiter (str), "display": whether to display in newline (bool)} that will be
used to render LaTeX expressions. If not provided, `latex_delimiters` is set
to `[{ "left": "$$", "right": "$$", "display": True }]`, so only expressions
enclosed in $$ delimiters will be rendered as LaTe... | Initialization | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
order). Pass
None for either the user or bot image to skip. Must be within the working
directory of the Gradio app or an external URL.
sanitize_html: bool
default `= True`
If False, will disable HTML sanitization for chatbot messages. This is not
recommended, as it can lead to security vulnerabilities... | Initialization | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
tered
vertically and horizontally in the Chatbot. Supports Markdown and HTML. If
None, no placeholder is displayed.
examples: list[ExampleMessage] | None
default `= None`
A list of example messages to display in the chatbot before any user/assistant
messages are shown. Each example should be a diction... | Initialization | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
and displayed in a separate collapsible
message with metadata={"title": "Reasoning"}. For example, [("<thinking>",
"</thinking>")] will extract content between <thinking> and </thinking> tags.
Each thinking block will be displayed as a separate collapsible message before
the main response. If None (default), no automa... | Initialization | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
Shortcuts
gradio.Chatbot
Interface String Shortcut `"chatbot"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
**Displaying Thoughts/Tool Usage**
You can provide additional metadata regarding any tools used to generate the
response. This is useful for displaying the thought process of LLM agents. For
example,
def generate_response(history):
history.append(
ChatMessage(role="assistant",
... | Examples | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
deo("https://github.com/gradio-app/gradio/raw/main/gradio/media_assets/videos/world.mp4")}
]
with gr.Blocks() as demo:
chatbot = gr.Chatbot()
button = gr.Button("Load audio and video")
button.click(load, None, chatbot)
demo.launch()
| Examples | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
chatbot_simplechatbot_streamingchatbot_with_toolschatbot_core_components
| Demos | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
Description
Event listeners allow you to respond to user interactions with the UI
components you've defined in a Gradio Blocks app. When a user interacts with
an element, such as changing a slider value or uploading an image, a function
is called.
Supported Event Listeners
The Chatbot component supports the followin... | Event Listeners | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
s event has SelectData of type gradio.SelectData that carries
information, accessible through SelectData.index and SelectData.value. See
SelectData documentation on how to use this event data.
Chatbot.option_select(fn, ···)
This listener is triggered when the user clicks on an option from within the
Cha... | Event Listeners | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
ckContext] | Set[Component | BlockContext] | None
default `= None`
List of gradio.components to use as outputs. If the function returns no
outputs, this should be an empty list.
api_name: str | None
default `= None`
defines how the endpoint appears in the API docs. Can be a string or None. If
set to... | Event Listeners | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
f the gradio app.
batch: bool
default `= False`
If True, then the function should process a batch of inputs, meaning that it
should accept a list of input values for each parameter. The lists should be
of equal length (and be up to length `max_batch_size`). The function is then
*required* to return a ... | Event Listeners | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
d submission after the
pending event is complete.
js: str | Literal[True] | None
default `= None`
Optional frontend js method to run before running 'fn'. Input arguments for js
method are values of 'inputs' and 'outputs', return should be a list of values
for output components.
concurr... | Event Listeners | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
= None`
Optional validation function to run before the main function. If provided,
this function will be executed first with queue=False, and only if it
completes successfully will the main function be called. The validator
receives the same inputs as the main function and should return a
`gr.validate()` for each inpu... | Event Listeners | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
Helper Classes | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs | |
gradio.ChatMessage(···)
Description
A dataclass that represents a message in the Chatbot component (with
type="messages"). The only required field is `content`. The value of
`gr.Chatbot` is a list of these dataclasses.
Parameters ▼
content: MessageContent | list[MessageContent]
The content of the me... | ChatMessage | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
A typed dictionary to represent metadata for a message in the Chatbot
component. An instance of this dictionary is used for the `metadata` field in
a ChatMessage when the chat message should be displayed as a thought.
Keys ▼
title: str
The title of the 'thought' message. Only required field.
... | MetadataDict | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
A typed dictionary to represent an option in a ChatMessage. A list of these
dictionaries is used for the `options` field in a ChatMessage.
Keys ▼
value: str
The value to return when the option is selected.
label: str
The text to display in the option, if different from the value.
[Ch... | OptionDict | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
Used to create an upload button, when clicked allows a user to upload files
that satisfy the specified file type or generic files (if file_type not set).
| Description | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
**Using UploadButton as an input component.**
How UploadButton will pass its value to your function:
Type: `bytes | str | list[bytes] | list[str] | None`
Passes the file as a `str` or `bytes` object, or a list of `str` or list of
`bytes` objects, depending on `type` and `file_count`.
Example Code
... | Behavior | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
Parameters ▼
label: str
default `= "Upload a File"`
Text to display on the button. Defaults to "Upload a File".
value: str | I18nData | list[str] | Callable | None
default `= None`
File or list of files to upload by default.
every: Timer | float | None
default `= Non... | Initialization | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
width: int | None
default `= None`
minimum pixel width, will wrap if not sufficient screen space to satisfy this
value. If a certain scale value results in this Component being narrower than
min_width, the min_width parameter will be respected first.
interactive: bool
default `= True`
If False, the ... | Initialization | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
th the same base name as the uploaded file, whose full path can be
retrieved by file_obj.name, "binary" returns an bytes object.
file_count: Literal['single', 'multiple', 'directory']
default `= "single"`
if single, allows user to upload one file. If "multiple", user uploads
multiple files. If "direct... | Initialization | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
Shortcuts
gradio.UploadButton
Interface String Shortcut `"uploadbutton"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
upload_and_downloadupload_button
| Demos | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
Description
Event listeners allow you to respond to user interactions with the UI
components you've defined in a Gradio Blocks app. When a user interacts with
an element, such as changing a slider value or uploading an image, a function
is called.
Supported Event Listeners
The UploadButton component supports the fol... | Event Listeners | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
] | None
default `= None`
List of gradio.components to use as outputs. If the function returns no
outputs, this should be an empty list.
api_name: str | None
default `= None`
defines how the endpoint appears in the API docs. Can be a string or None. If
set to a string, the endpoint will be exposed i... | Event Listeners | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
bool
default `= False`
If True, then the function should process a batch of inputs, meaning that it
should accept a list of input values for each parameter. The lists should be
of equal length (and be up to length `max_batch_size`). The function is then
*required* to return a tuple of lists (even if there is only 1 o... | Event Listeners | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
omplete.
js: str | Literal[True] | None
default `= None`
Optional frontend js method to run before running 'fn'. Input arguments for js
method are values of 'inputs' and 'outputs', return should be a list of values
for output components.
concurrency_limit: int | None | Literal['default... | Event Listeners | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
run before the main function. If provided,
this function will be executed first with queue=False, and only if it
completes successfully will the main function be called. The validator
receives the same inputs as the main function and should return a
`gr.validate()` for each input value.
| Event Listeners | https://gradio.app/docs/gradio/uploadbutton | Gradio - Uploadbutton Docs |
Creates a color picker for user to select a color as string input. Can be
used as an input to pass a color value to a function or as an output to
display a color value.
| Description | https://gradio.app/docs/gradio/colorpicker | Gradio - Colorpicker Docs |
**Using ColorPicker as an input component.**
How ColorPicker will pass its value to your function:
Type: `str | None`
Passes selected color value as a hex `str` into the function.
Example Code
import gradio as gr
def predict(
value: str | None
):
... | Behavior | https://gradio.app/docs/gradio/colorpicker | Gradio - Colorpicker Docs |
Parameters ▼
value: str | Callable | None
default `= None`
default color hex code to provide in color picker. If a function is provided,
the function will be called each time the app loads to set the initial value
of this component.
label: str | I18nData | None
default `= None`
the l... | Initialization | https://gradio.app/docs/gradio/colorpicker | Gradio - Colorpicker Docs |
to top-level Components
in Blocks where fill_height=True.
min_width: int
default `= 160`
minimum pixel width, will wrap if not sufficient screen space to satisfy this
value. If a certain scale value results in this Component being narrower than
min_width, the min_width parameter will be respected fir... | Initialization | https://gradio.app/docs/gradio/colorpicker | Gradio - Colorpicker Docs |
render()
function, if a component is re-rendered with the same key, these (and only
these) parameters will be preserved in the UI (if they have been changed by
the user or an event listener) instead of re-rendered based on the values
provided during constructor.
| Initialization | https://gradio.app/docs/gradio/colorpicker | Gradio - Colorpicker Docs |
Shortcuts
gradio.ColorPicker
Interface String Shortcut `"colorpicker"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/colorpicker | Gradio - Colorpicker Docs |
color_picker
| Demos | https://gradio.app/docs/gradio/colorpicker | Gradio - Colorpicker Docs |
Description
Event listeners allow you to respond to user interactions with the UI
components you've defined in a Gradio Blocks app. When a user interacts with
an element, such as changing a slider value or uploading an image, a function
is called.
Supported Event Listeners
The ColorPicker component supports the foll... | Event Listeners | https://gradio.app/docs/gradio/colorpicker | Gradio - Colorpicker Docs |
ing to one output component.
inputs: Component | BlockContext | list[Component | BlockContext] | Set[Component | BlockContext] | None
default `= None`
List of gradio.components to use as inputs. If the function takes no inputs,
this should be an empty list.
outputs: Component | BlockCo... | Event Listeners | https://gradio.app/docs/gradio/colorpicker | Gradio - Colorpicker Docs |
the progress animation on. If None,
will show the progress animation on all of the output components.
queue: bool
default `= True`
If True, will place the request on the queue, if the queue has been enabled.
If False, will not put this event on the queue, even if the queue has been
enabled. If None, ... | Event Listeners | https://gradio.app/docs/gradio/colorpicker | Gradio - Colorpicker Docs |
er_mode: Literal['once', 'multiple', 'always_last'] | None
default `= None`
If "once" (default for all events except `.change()`) would not allow any
submissions while an event is pending. If set to "multiple", unlimited
submissions are allowed while pending, and "always_last" (default for
`.change()` and `.key_up()`... | Event Listeners | https://gradio.app/docs/gradio/colorpicker | Gradio - Colorpicker Docs |
stream_every: float
default `= 0.5`
key: int | str | tuple[int | str, ...] | None
default `= None`
A unique key for this event listener to be used in @gr.render(). If set, this
value identifies an event as identical across re-renders when the key is
identical.
validator... | Event Listeners | https://gradio.app/docs/gradio/colorpicker | Gradio - Colorpicker Docs |
Displays text that contains spans that are highlighted by category or
numerical value.
| Description | https://gradio.app/docs/gradio/highlightedtext | Gradio - Highlightedtext Docs |
**Using HighlightedText as an input component.**
How HighlightedText will pass its value to your function:
Type: `list[tuple[str, str | float | None]] | None`
Passes the value as a list of tuples: `list[tuple]`. Each `tuple` consists of:
* a `str` substring of the text (so the entire text is included)
* a `str... | Behavior | https://gradio.app/docs/gradio/highlightedtext | Gradio - Highlightedtext Docs |
Parameters ▼
value: list[tuple[str, str | float | None]] | dict | Callable | None
default `= None`
Default value to show. If a function is provided, the function will be called
each time the app loads to set the initial value of this component.
color_map: dict[str, str] | None
default... | Initialization | https://gradio.app/docs/gradio/highlightedtext | Gradio - Highlightedtext Docs |
inputs: Component | list[Component] | set[Component] | None
default `= None`
Components that are used as inputs to calculate `value` if `value` is a
function (has no effect otherwise). `value` is recalculated any time the
inputs change.
show_label: bool | None
default `= None`
if True, will displa... | Initialization | https://gradio.app/docs/gradio/highlightedtext | Gradio - Highlightedtext Docs |
he intention is to assign event listeners now but render the
component later.
key: int | str | tuple[int | str, ...] | None
default `= None`
in a gr.render, Components with the same key across re-renders are treated as
the same component, not a new component. Properties set in 'preserved_by_key'
are n... | Initialization | https://gradio.app/docs/gradio/highlightedtext | Gradio - Highlightedtext Docs |
Shortcuts
gradio.HighlightedText
Interface String Shortcut `"highlightedtext"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/highlightedtext | Gradio - Highlightedtext Docs |
diff_texts
| Demos | https://gradio.app/docs/gradio/highlightedtext | Gradio - Highlightedtext Docs |
Description
Event listeners allow you to respond to user interactions with the UI
components you've defined in a Gradio Blocks app. When a user interacts with
an element, such as changing a slider value or uploading an image, a function
is called.
Supported Event Listeners
The HighlightedText component supports the ... | Event Listeners | https://gradio.app/docs/gradio/highlightedtext | Gradio - Highlightedtext Docs |
puts,
this should be an empty list.
outputs: Component | BlockContext | list[Component | BlockContext] | Set[Component | BlockContext] | None
default `= None`
List of gradio.components to use as outputs. If the function returns no
outputs, this should be an empty list.
api_name: str | ... | Event Listeners | https://gradio.app/docs/gradio/highlightedtext | Gradio - Highlightedtext Docs |
l not put this event on the queue, even if the queue has been
enabled. If None, will use the queue setting of the gradio app.
batch: bool
default `= False`
If True, then the function should process a batch of inputs, meaning that it
should accept a list of input values for each parameter. The lists sh... | Event Listeners | https://gradio.app/docs/gradio/highlightedtext | Gradio - Highlightedtext Docs |
llowed while pending, and "always_last" (default for
`.change()` and `.key_up()` events) would allow a second submission after the
pending event is complete.
js: str | Literal[True] | None
default `= None`
Optional frontend js method to run before running 'fn'. Input arguments for js
method are values... | Event Listeners | https://gradio.app/docs/gradio/highlightedtext | Gradio - Highlightedtext Docs |
identical across re-renders when the key is
identical.
validator: Callable | None
default `= None`
Optional validation function to run before the main function. If provided,
this function will be executed first with queue=False, and only if it
completes successfully will the main function be called. T... | Event Listeners | https://gradio.app/docs/gradio/highlightedtext | Gradio - Highlightedtext Docs |
Creates a dropdown of choices from which a single entry or multiple entries
can be selected (as an input component) or displayed (as an output component).
| Description | https://gradio.app/docs/gradio/dropdown | Gradio - Dropdown Docs |
**Using Dropdown as an input component.**
How Dropdown will pass its value to your function:
Type: `str | int | float | list[str | int | float] | list[int | None] | None`
Passes the value of the selected dropdown choice as a `str | int | float` or its index as an `int` into the function, depending on `type`. Or, if ... | Behavior | https://gradio.app/docs/gradio/dropdown | Gradio - Dropdown Docs |
Parameters ▼
choices: list[str | int | float | tuple[str | I18nData, str | int | float]] | None
default `= None`
a list of string or numeric options to choose from. An option can also be a
tuple of the form (name, value), where name is the displayed name of the
dropdown choice and value is the value t... | Initialization | https://gradio.app/docs/gradio/dropdown | Gradio - Dropdown Docs |
component if `show_label` is
`True` and is also used as the header if there are a table of examples for
this component. If None and used in a `gr.Interface`, the label will be the
name of the parameter this component corresponds to.
info: str | I18nData | None
default `= None`
additional component des... | Initialization | https://gradio.app/docs/gradio/dropdown | Gradio - Dropdown Docs |
default `= None`
if True, choices in this dropdown will be selectable; if False, selection will
be disabled. If not provided, this is inferred based on whether the component
is used as an input or output.
visible: bool | Literal['hidden']
default `= True`
If False, component will be hidden. If "hidd... | Initialization | https://gradio.app/docs/gradio/dropdown | Gradio - Dropdown Docs |
Shortcuts
gradio.Dropdown
Interface String Shortcut `"dropdown"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/dropdown | Gradio - Dropdown Docs |
sentence_builder
| Demos | https://gradio.app/docs/gradio/dropdown | Gradio - Dropdown Docs |
Description
Event listeners allow you to respond to user interactions with the UI
components you've defined in a Gradio Blocks app. When a user interacts with
an element, such as changing a slider value or uploading an image, a function
is called.
Supported Event Listeners
The Dropdown component supports the followi... | Event Listeners | https://gradio.app/docs/gradio/dropdown | Gradio - Dropdown Docs |
he function corresponds to one
input component, and the function should return a single value or a tuple of
values, with each element in the tuple corresponding to one output component.
inputs: Component | BlockContext | list[Component | BlockContext] | Set[Component | BlockContext] | None
default `= N... | Event Listeners | https://gradio.app/docs/gradio/dropdown | Gradio - Dropdown Docs |
no progress animation at all
show_progress_on: Component | list[Component] | None
default `= None`
Component or list of components to show the progress animation on. If None,
will show the progress animation on all of the output components.
queue: bool
default `= True`
If True, will... | Event Listeners | https://gradio.app/docs/gradio/dropdown | Gradio - Dropdown Docs |
e
not yet run (or generators that are iterating) will be cancelled, but
functions that are currently running will be allowed to finish.
trigger_mode: Literal['once', 'multiple', 'always_last'] | None
default `= None`
If "once" (default for all events except `.change()`) would not allow any
submissions... | Event Listeners | https://gradio.app/docs/gradio/dropdown | Gradio - Dropdown Docs |
by clients and via gr.load). If fn is None,
api_visibility will automatically be set to "private".
time_limit: int | None
default `= None`
stream_every: float
default `= 0.5`
key: int | str | tuple[int | str, ...] | None
default `= None`
A unique key for this event li... | Event Listeners | https://gradio.app/docs/gradio/dropdown | Gradio - Dropdown Docs |
Creates a component to displays a base image and colored annotations on top
of that image. Annotations can take the from of rectangles (e.g. object
detection) or masks (e.g. image segmentation). As this component does not
accept user input, it is rarely used as an input component.
| Description | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
**Using AnnotatedImage as an input component.**
How AnnotatedImage will pass its value to your function:
Type: `tuple[str, list[tuple[str, str]]] | None`
Passes its value as a `tuple` consisting of:
* `str` filepath to a base image
* `list` of annotations.
* Each annotation itself is a `tuple` of a mask (... | Behavior | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
Parameters ▼
value: tuple[np.ndarray | PIL.Image.Image | str, list[tuple[np.ndarray | tuple[int, int, int, int], str]]] | None
default `= None`
Tuple of base image and list of (annotation, label) pairs.
format: str
default `= "webp"`
Format used to save images before it is returned t... | Initialization | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
ect otherwise). Can provide a Timer whose tick resets `value`, or a float
that provides the regular interval for the reset Timer.
inputs: Component | list[Component] | set[Component] | None
default `= None`
Components that are used as inputs to calculate `value` if `value` is a
function (has no effect... | Initialization | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
e rendered in the Blocks context. Should
be used if the intention is to assign event listeners now but render the
component later.
key: int | str | tuple[int | str, ...] | None
default `= None`
in a gr.render, Components with the same key across re-renders are treated as
the same component, not a new ... | Initialization | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
Shortcuts
gradio.AnnotatedImage
Interface String Shortcut `"annotatedimage"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
image_segmentation
| Demos | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
Description
Event listeners allow you to respond to user interactions with the UI
components you've defined in a Gradio Blocks app. When a user interacts with
an element, such as changing a slider value or uploading an image, a function
is called.
Supported Event Listeners
The AnnotatedImage component supports the f... | Event Listeners | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
his should be an empty list.
outputs: Component | BlockContext | list[Component | BlockContext] | Set[Component | BlockContext] | None
default `= None`
List of gradio.components to use as outputs. If the function returns no
outputs, this should be an empty list.
api_name: str | None
d... | Event Listeners | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
ut this event on the queue, even if the queue has been
enabled. If None, will use the queue setting of the gradio app.
batch: bool
default `= False`
If True, then the function should process a batch of inputs, meaning that it
should accept a list of input values for each parameter. The lists should be... | Event Listeners | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
while pending, and "always_last" (default for
`.change()` and `.key_up()` events) would allow a second submission after the
pending event is complete.
js: str | Literal[True] | None
default `= None`
Optional frontend js method to run before running 'fn'. Input arguments for js
method are values of 'in... | Event Listeners | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
al across re-renders when the key is
identical.
validator: Callable | None
default `= None`
Optional validation function to run before the main function. If provided,
this function will be executed first with queue=False, and only if it
completes successfully will the main function be called. The vali... | Event Listeners | https://gradio.app/docs/gradio/annotatedimage | Gradio - Annotatedimage Docs |
Special component that ticks at regular intervals when active. It is not
visible, and only used to trigger events at a regular interval through the
`tick` event listener.
| Description | https://gradio.app/docs/gradio/timer | Gradio - Timer Docs |
**Using Timer as an input component.**
How Timer will pass its value to your function:
Type: `float | None`
The interval of the timer as a float.
Example Code
import gradio as gr
def predict(
value: float | None
):
process value from the Timer... | Behavior | https://gradio.app/docs/gradio/timer | Gradio - Timer Docs |
Parameters ▼
value: float
default `= 1`
Interval in seconds between each tick.
active: bool
default `= True`
Whether the timer is active.
render: bool
default `= True`
If False, component will not render be rendered in the Blocks context. Should
be used if the inten... | Initialization | https://gradio.app/docs/gradio/timer | Gradio - Timer Docs |
Shortcuts
gradio.Timer
Interface String Shortcut `"timer"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/timer | Gradio - Timer Docs |
Description
Event listeners allow you to respond to user interactions with the UI
components you've defined in a Gradio Blocks app. When a user interacts with
an element, such as changing a slider value or uploading an image, a function
is called.
Supported Event Listeners
The Timer component supports the following ... | Event Listeners | https://gradio.app/docs/gradio/timer | Gradio - Timer Docs |
empty list.
api_name: str | None
default `= None`
defines how the endpoint appears in the API docs. Can be a string or None. If
set to a string, the endpoint will be exposed in the API docs with the given
name. If None (default), the name of the function will be used as the API
endpoint.
... | Event Listeners | https://gradio.app/docs/gradio/timer | Gradio - Timer Docs |
nput values for each parameter. The lists should be
of equal length (and be up to length `max_batch_size`). The function is then
*required* to return a tuple of lists (even if there is only 1 output
component), with each list in the tuple corresponding to one output component.
max_batch_size: int
defau... | Event Listeners | https://gradio.app/docs/gradio/timer | Gradio - Timer Docs |
n'. Input arguments for js
method are values of 'inputs' and 'outputs', return should be a list of values
for output components.
concurrency_limit: int | None | Literal['default']
default `= "default"`
If set, this is the maximum number of this event that can be running
simultaneously. Can be set to N... | Event Listeners | https://gradio.app/docs/gradio/timer | Gradio - Timer Docs |
essfully will the main function be called. The validator
receives the same inputs as the main function and should return a
`gr.validate()` for each input value.
[More Blocks Features](../../guides/more-blocks-features/)[Time
Plots](../../guides/time-plots/)
| Event Listeners | https://gradio.app/docs/gradio/timer | Gradio - Timer Docs |
The gr.DeletedFileData class is a subclass of gr.EventData that
specifically carries information about the `.delete()` event. When
gr.DeletedFileData is added as a type hint to an argument of an event listener
method, a gr.DeletedFileData object will automatically be passed as the value
of that argument. The attributes... | Description | https://gradio.app/docs/gradio/deletedfiledata | Gradio - Deletedfiledata Docs |
import gradio as gr
def test(delete_data: gr.DeletedFileData):
return delete_data.file.path
with gr.Blocks() as demo:
files = gr.File(file_count="multiple")
deleted_file = gr.File()
files.delete(test, None, deleted_file)
demo.launch()
| Example Usage | https://gradio.app/docs/gradio/deletedfiledata | Gradio - Deletedfiledata Docs |
Parameters ▼
file: FileData
The file that was deleted, as a FileData object. The str path to the file can
be retrieved with the .path attribute.
| Attributes | https://gradio.app/docs/gradio/deletedfiledata | Gradio - Deletedfiledata Docs |
file_component_events
| Demos | https://gradio.app/docs/gradio/deletedfiledata | Gradio - Deletedfiledata Docs |
Creates a button that can be assigned arbitrary .click() events. The value
(label) of the button can be used as an input to the function (rarely used) or
set via the output of a function.
| Description | https://gradio.app/docs/gradio/button | Gradio - Button Docs |
**Using Button as an input component.**
How Button will pass its value to your function:
Type: `str | None`
(Rarely used) the `str` corresponding to the button label when the button is
clicked
Example Code
import gradio as gr
def predict(
value: str | None
... | Behavior | https://gradio.app/docs/gradio/button | Gradio - Button Docs |
Parameters ▼
value: str | I18nData | Callable
default `= "Run"`
default text for the button to display. If a function is provided, the
function will be called each time the app loads to set the initial value of
this component.
every: Timer | float | None
default `= None`
continuously... | Initialization | https://gradio.app/docs/gradio/button | Gradio - Button Docs |
iteral['hidden']
default `= True`
If False, component will be hidden. If "hidden", component will be visually
hidden and not take up space in the layout but still exist in the DOM
interactive: bool
default `= True`
if False, the Button will be in a disabled state.
elem_id: str | None... | Initialization | https://gradio.app/docs/gradio/button | Gradio - Button Docs |
scale applies in Rows, and to top-level Components
in Blocks where fill_height=True.
min_width: int | None
default `= None`
minimum pixel width, will wrap if not sufficient screen space to satisfy this
value. If a certain scale value results in this Component being narrower than
min_width, the min_wid... | Initialization | https://gradio.app/docs/gradio/button | Gradio - Button Docs |
Shortcuts
gradio.Button
Interface String Shortcut `"button"`
Initialization Uses default values
gradio.ClearButton
Interface String Shortcut `"clearbutton"`
Initialization Uses default values
gradio.DeepLinkButton
Interface String Shortcut `"deeplinkbutton"`
Initializa... | Shortcuts | https://gradio.app/docs/gradio/button | Gradio - Button Docs |
Description
Event listeners allow you to respond to user interactions with the UI
components you've defined in a Gradio Blocks app. When a user interacts with
an element, such as changing a slider value or uploading an image, a function
is called.
Supported Event Listeners
The Button component supports the following... | Event Listeners | https://gradio.app/docs/gradio/button | Gradio - Button Docs |
api_name: str | None
default `= None`
defines how the endpoint appears in the API docs. Can be a string or None. If
set to a string, the endpoint will be exposed in the API docs with the given
name. If None (default), the name of the function will be used as the API
endpoint.
api_description: str | N... | Event Listeners | https://gradio.app/docs/gradio/button | Gradio - Button Docs |
ter. The lists should be
of equal length (and be up to length `max_batch_size`). The function is then
*required* to return a tuple of lists (even if there is only 1 output
component), with each list in the tuple corresponding to one output component.
max_batch_size: int
default `= 4`
Maximum number of... | Event Listeners | https://gradio.app/docs/gradio/button | Gradio - Button Docs |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.