text stringlengths 0 2k | heading1 stringlengths 3 79 | source_page_url stringclasses 188
values | source_page_title stringclasses 188
values |
|---|---|---|---|
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 LoginButton component supports the foll... | Event Listeners | https://gradio.app/docs/gradio/loginbutton | Gradio - Loginbutton Docs |
ion: str | None | Literal[False]
default `= None`
Description of the API endpoint. Can be a string, None, or False. If set to a
string, the endpoint will be exposed in the API docs with the given
description. If None, the function's docstring will be used as the API
endpoint description. If False, then no description... | Event Listeners | https://gradio.app/docs/gradio/loginbutton | Gradio - Loginbutton Docs |
um number of inputs to batch together if this is called from the queue
(only relevant if batch=True)
preprocess: bool
default `= True`
If False, will not run preprocessing of component data before running 'fn'
(e.g. leaving it as a base64 string if this method is called with the `Image`
component).
... | Event Listeners | https://gradio.app/docs/gradio/loginbutton | Gradio - Loginbutton Docs |
concurrency_limit (any number of
this event can be running simultaneously). Set to "default" to use the default
concurrency limit (defined by the `default_concurrency_limit` parameter in
`Blocks.queue()`, which itself is 1 by default).
concurrency_id: str | None
default `= None`
If set, this is the id... | Event Listeners | https://gradio.app/docs/gradio/loginbutton | Gradio - Loginbutton Docs |
Sets up an API or MCP endpoint for a generic function without needing
define events listeners or components. Derives its typing from type hints in
the provided function's signature rather than the components.
| Description | https://gradio.app/docs/gradio/api | Gradio - Api Docs |
import gradio as gr
with gr.Blocks() as demo:
with gr.Row():
input = gr.Textbox()
button = gr.Button("Submit")
output = gr.Textbox()
def fn(a: int, b: int, c: list[str]) -> tuple[int, str]:
return a + b, c[a:b]
gr.api(fn, api_name="add_and_slice")
... | Example Usage | https://gradio.app/docs/gradio/api | Gradio - Api Docs |
Parameters ▼
fn: Callable | Literal['decorator']
default `= "decorator"`
the function to call when this event is triggered. Often a machine learning
model's prediction function. The function should be fully typed, and the type
hints will be used to derive the typing information for the API/MCP endpoin... | Initialization | https://gradio.app/docs/gradio/api | Gradio - Api Docs |
eue
(only relevant if batch=True)
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 None to mean no concurrency_limit (any number of
this event can be running simultaneously). Set ... | Initialization | https://gradio.app/docs/gradio/api | Gradio - Api Docs |
Component to select a date and (optionally) a time.
| Description | https://gradio.app/docs/gradio/datetime | Gradio - Datetime Docs |
**Using DateTime as an input component.**
How DateTime will pass its value to your function:
Type: `str | float | datetime | None`
Passes text value as a `str` into the function.
Example Code
import gradio as gr
def predict(
value: str | float | datetime | None
... | Behavior | https://gradio.app/docs/gradio/datetime | Gradio - Datetime Docs |
Parameters ▼
value: float | str | datetime | None
default `= None`
default value for datetime.
include_time: bool
default `= True`
If True, the component will include time selection. If False, only date
selection will be available.
type: Literal['timestamp', 'datetime... | Initialization | https://gradio.app/docs/gradio/datetime | Gradio - Datetime Docs |
nents. For example if Components A and
B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide
as B. Should be an integer. scale applies in Rows, and to top-level Components
in Blocks where fill_height=True.
min_width: int
default `= 160`
minimum pixel width, will wrap if not suf... | Initialization | https://gradio.app/docs/gradio/datetime | Gradio - Datetime Docs |
y have been changed by
the user or an event listener) instead of re-rendered based on the values
provided during constructor.
buttons: list[Button] | None
default `= None`
A list of gr.Button() instances to show in the top right corner of the
component. Custom buttons will appear in the toolbar with t... | Initialization | https://gradio.app/docs/gradio/datetime | Gradio - Datetime Docs |
Shortcuts
gradio.DateTime
Interface String Shortcut `"datetime"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/datetime | Gradio - Datetime 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 DateTime component supports the followi... | Event Listeners | https://gradio.app/docs/gradio/datetime | Gradio - Datetime Docs |
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 in the API docs with the given
name. If None (default), the name of the function will be u... | Event Listeners | https://gradio.app/docs/gradio/datetime | Gradio - Datetime Docs |
ning 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 output
component), with each list in the tuple corresponding to one output component.
... | Event Listeners | https://gradio.app/docs/gradio/datetime | Gradio - Datetime Docs |
end 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']
default `= "default"`
If set, this is the maximum number of this event that can be r... | Event Listeners | https://gradio.app/docs/gradio/datetime | Gradio - Datetime Docs |
e=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.
[Time Plots](../../guides/time-plots/)
| Event Listeners | https://gradio.app/docs/gradio/datetime | Gradio - Datetime Docs |
Creates a code editor for viewing code (as an output component), or for
entering and editing code (as an input component).
| Description | https://gradio.app/docs/gradio/code | Gradio - Code Docs |
**Using Code as an input component.**
How Code will pass its value to your function:
Type: `str | None`
Passes the code entered as a `str`.
Example Code
import gradio as gr
def predict(
value: str | None
):
process value from the Code componen... | Behavior | https://gradio.app/docs/gradio/code | Gradio - Code Docs |
Parameters ▼
value: str | Callable | None
default `= None`
Default value to show in the code editor. If a function is provided, the
function will be called each time the app loads to set the initial value of
this component.
language: Literal['python', 'c', 'cpp', 'markdown', 'latex', '... | Initialization | https://gradio.app/docs/gradio/code | Gradio - Code Docs |
component is assigned to.
interactive: bool | None
default `= None`
Whether user should be able to enter code or only view it.
show_label: bool | None
default `= None`
if True, will display label.
container: bool
default `= True`
If True, will place the component i... | Initialization | https://gradio.app/docs/gradio/code | Gradio - Code Docs |
ey: 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 not reset across a re-render.
preserved_by_key: list[str] | str | None
default ... | Initialization | https://gradio.app/docs/gradio/code | Gradio - Code Docs |
Shortcuts
gradio.Code
Interface String Shortcut `"code"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/code | Gradio - Code 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 Code component supports the following e... | Event Listeners | https://gradio.app/docs/gradio/code | Gradio - Code 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 |
api_description: str | None | Literal[False]
default `= None`
Description of the API endpoint. Can be a string, None, or False. If set to a
string, the endpoint will be exposed in the API docs with the given
description. If None, the function's docstring will be used as the API
endpoint description. If False, ... | Event Listeners | https://gradio.app/docs/gradio/timer | Gradio - Timer Docs |
default `= 4`
Maximum number of inputs to batch together if this is called from the queue
(only relevant if batch=True)
preprocess: bool
default `= True`
If False, will not run preprocessing of component data before running 'fn'
(e.g. leaving it as a base64 string if this method is called with the `... | Event Listeners | https://gradio.app/docs/gradio/timer | Gradio - Timer Docs |
t to None to mean no concurrency_limit (any number of
this event can be running simultaneously). Set to "default" to use the default
concurrency limit (defined by the `default_concurrency_limit` parameter in
`Blocks.queue()`, which itself is 1 by default).
concurrency_id: str | None
default `= None`
I... | Event Listeners | https://gradio.app/docs/gradio/timer | Gradio - Timer Docs |
When gr.EventData or one of its subclasses is added as a type hint to an
argument of a prediction function, a gr.EventData object will automatically be
passed as the value of that argument. The attributes of this object contains
information about the event that triggered the listener. The gr.EventData
object itself con... | Description | https://gradio.app/docs/gradio/eventdata | Gradio - Eventdata Docs |
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):
... | Example Usage | https://gradio.app/docs/gradio/eventdata | Gradio - Eventdata Docs |
Parameters ▼
target: Block | None
The component object that triggered the event. Can be used to distinguish
multiple components bound to the same listener.
| Attributes | https://gradio.app/docs/gradio/eventdata | Gradio - Eventdata Docs |
gallery_selectionstictactoe
[Blocks And Event Listeners](../../guides/blocks-and-event-listeners/)
| Demos | https://gradio.app/docs/gradio/eventdata | Gradio - Eventdata Docs |
Set the static paths to be served by the gradio app.
Static files are are served directly from the file system instead of being
copied. They are served to users with The Content-Disposition HTTP header set
to "inline" when sending these files to users. This indicates that the file
should be displayed directly in the ... | Description | https://gradio.app/docs/gradio/set_static_paths | Gradio - Set_Static_Paths Docs |
import gradio as gr
Paths can be a list of strings or pathlib.Path objects
corresponding to filenames or directories.
gr.set_static_paths(paths=["test/test_files/"])
The example files and the default value of the input
will not be copied to the gradio cache and will be served directly.
... | Example Usage | https://gradio.app/docs/gradio/set_static_paths | Gradio - Set_Static_Paths Docs |
Parameters ▼
paths: str | pathlib.Path | list[str | pathlib.Path]
filepath or list of filepaths or directory names to be served by the gradio
app. If it is a directory name, ALL files located within that directory will
be considered static and not moved to the gradio cache. This also means that
ALL fil... | Initialization | https://gradio.app/docs/gradio/set_static_paths | Gradio - Set_Static_Paths Docs |
Creates an image component that can be used to upload images (as an input)
or display images (as an output).
| Description | https://gradio.app/docs/gradio/simpleimage | Gradio - Simpleimage Docs |
**Using SimpleImage as an input component.**
How SimpleImage will pass its value to your function:
Type: `str | None`
A `str` containing the path to the image.
Example Code
import gradio as gr
def predict(
value: str | None
):
process value fr... | Behavior | https://gradio.app/docs/gradio/simpleimage | Gradio - Simpleimage Docs |
Parameters ▼
value: str | None
default `= None`
A path or URL for the default value that SimpleImage component is going to
take. 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
defa... | Initialization | https://gradio.app/docs/gradio/simpleimage | Gradio - Simpleimage Docs |
ll_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 first.
interactive: bool | Non... | Initialization | https://gradio.app/docs/gradio/simpleimage | Gradio - Simpleimage Docs |
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/simpleimage | Gradio - Simpleimage Docs |
Shortcuts
gradio.SimpleImage
Interface String Shortcut `"simpleimage"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/simpleimage | Gradio - Simpleimage 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 SimpleImage component supports the foll... | Event Listeners | https://gradio.app/docs/gradio/simpleimage | Gradio - Simpleimage Docs |
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
default `= None`
defines how the endpoint appears in the API docs. Can be a string or ... | Event Listeners | https://gradio.app/docs/gradio/simpleimage | Gradio - Simpleimage Docs |
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
of equal length (and be up to length `max_batch_size`). The function is then
*require... | Event Listeners | https://gradio.app/docs/gradio/simpleimage | Gradio - Simpleimage Docs |
d 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 'inputs' and 'outputs', return should be a list of values
for output components.
... | Event Listeners | https://gradio.app/docs/gradio/simpleimage | Gradio - Simpleimage Docs |
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 validator
receives the same inputs as the main function and should return a
`gr.validate()... | Event Listeners | https://gradio.app/docs/gradio/simpleimage | Gradio - Simpleimage Docs |
Creates a set of (string or numeric type) radio buttons of which only one
can be selected.
| Description | https://gradio.app/docs/gradio/radio | Gradio - Radio Docs |
**Using Radio as an input component.**
How Radio will pass its value to your function:
Type: `str | int | float | None`
Passes the value of the selected radio button as a `str | int | float`, or its index as an `int` into the function, depending on `type`.
Example Code
import gradio as g... | Behavior | https://gradio.app/docs/gradio/radio | Gradio - Radio Docs |
Parameters ▼
choices: list[str | int | float | tuple[str, str | int | float]] | None
default `= None`
A list of string or numeric options to select from. An option can also be a
tuple of the form (name, value), where name is the displayed name of the radio
button and value is the value to be passed to... | Initialization | https://gradio.app/docs/gradio/radio | Gradio - Radio Docs |
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 display label.
container: bool
default `= True`
If True, will place the component in a container - providing some extra
padding a... | Initialization | https://gradio.app/docs/gradio/radio | Gradio - Radio Docs |
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 component. Properties set in 'pres... | Initialization | https://gradio.app/docs/gradio/radio | Gradio - Radio Docs |
Shortcuts
gradio.Radio
Interface String Shortcut `"radio"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/radio | Gradio - Radio Docs |
sentence_builderblocks_essay
| Demos | https://gradio.app/docs/gradio/radio | Gradio - Radio 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 Radio component supports the following ... | Event Listeners | https://gradio.app/docs/gradio/radio | Gradio - Radio Docs |
e as inputs. If the function takes no inputs,
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 empt... | Event Listeners | https://gradio.app/docs/gradio/radio | Gradio - Radio Docs |
he queue has been enabled.
If False, will 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... | Event Listeners | https://gradio.app/docs/gradio/radio | Gradio - Radio Docs |
"multiple", unlimited
submissions are allowed 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'. ... | Event Listeners | https://gradio.app/docs/gradio/radio | Gradio - Radio Docs |
set, this
value identifies an event as 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 successf... | Event Listeners | https://gradio.app/docs/gradio/radio | Gradio - Radio Docs |
Sets up an event listener that triggers a function when the specified
event(s) occur. This is especially useful when the same function should be
triggered by multiple events. Only a single API endpoint is generated for all
events in the triggers list.
| Description | https://gradio.app/docs/gradio/on | Gradio - On Docs |
import gradio as gr
with gr.Blocks() as demo:
with gr.Row():
input = gr.Textbox()
button = gr.Button("Submit")
output = gr.Textbox()
gr.on(
triggers=[button.click, input.submit],
fn=lambda x: x,
inputs=[input],
outp... | Example Usage | https://gradio.app/docs/gradio/on | Gradio - On Docs |
Parameters ▼
triggers: list[Trigger] | Trigger | None
default `= None`
List of triggers to listen to, e.g. [btn.click, number.change]. If None, will
run on app load and changes to any inputs.
fn: Callable[..., Any] | None | Literal['decorator']
default `= "decorator"`
the function to... | Initialization | https://gradio.app/docs/gradio/on | Gradio - On Docs |
lt), the name of the function will be used as the API
endpoint.
api_description: str | None | Literal[False]
default `= None`
scroll_to_output: bool
default `= False`
If True, will scroll to output component on completion
show_progress: Literal['full', 'minimal', 'hidd... | Initialization | https://gradio.app/docs/gradio/on | Gradio - On Docs |
re running 'fn'
(e.g. leaving it as a base64 string if this method is called with the `Image`
component).
postprocess: bool
default `= True`
If False, will not run postprocessing of component data before returning 'fn'
output to the browser.
cancels: dict[str, Any] | list[dict[str, Any... | Initialization | https://gradio.app/docs/gradio/on | Gradio - On Docs |
default).
concurrency_id: str | None
default `= None`
If set, this is the id of the concurrency group. Events with the same
concurrency_id will be limited by the lowest set concurrency_limit.
time_limit: int | None
default `= None`
The time limit for the function to run. Parameter on... | Initialization | https://gradio.app/docs/gradio/on | Gradio - On Docs |
Creates an image component that can be used to upload images (as an input)
or display images (as an output).
| Description | https://gradio.app/docs/gradio/imageslider | Gradio - Imageslider Docs |
**Using ImageSlider as an input component.**
How ImageSlider will pass its value to your function:
Type: `image_tuple | None`
Passes the uploaded image as a tuple of `numpy.array`, `PIL.Image` or `str`
filepath depending on `type`.
Example Code
import gradio as gr
def predic... | Behavior | https://gradio.app/docs/gradio/imageslider | Gradio - Imageslider Docs |
Parameters ▼
value: image_tuple | Callable | None
default `= None`
A tuple of PIL Image, numpy array, path or URL for the default value that
ImageSlider component is going to take, this pair of images should be of equal
size. If a function is provided, the function will be called each time the app
loa... | Initialization | https://gradio.app/docs/gradio/imageslider | Gradio - Imageslider Docs |
image_mode will be inferred
from the image file types (e.g. "RGBA" for a .png image, "RGB" in most other
cases).
type: Literal['numpy', 'pil', 'filepath']
default `= "numpy"`
The format the images are converted to before being passed into the prediction
function. "numpy" converts the images to numpy a... | Initialization | https://gradio.app/docs/gradio/imageslider | Gradio - Imageslider Docs |
ce. The
"download" button allows the user to download the image. The "fullscreen"
button allows the user to view the image in fullscreen mode. Custom
gr.Button() instances will appear in the toolbar with their configured icon
and/or label, and clicking them will trigger any .click() events registered on
the button. by ... | Initialization | https://gradio.app/docs/gradio/imageslider | Gradio - Imageslider Docs |
None
default `= None`
An optional list of strings that are assigned as the classes of this component
in the HTML DOM. Can be used for targeting CSS styles.
render: bool
default `= True`
If False, component will not render be rendered in the Blocks context. Should
be used if the intention is to assig... | Initialization | https://gradio.app/docs/gradio/imageslider | Gradio - Imageslider Docs |
Shortcuts
gradio.ImageSlider
Interface String Shortcut `"imageslider"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/imageslider | Gradio - Imageslider Docs |
imageslider
| Demos | https://gradio.app/docs/gradio/imageslider | Gradio - Imageslider 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 ImageSlider component supports the foll... | Event Listeners | https://gradio.app/docs/gradio/imageslider | Gradio - Imageslider Docs |
red. Often a machine learning
model's prediction function. Each parameter of the 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[... | Event Listeners | https://gradio.app/docs/gradio/imageslider | Gradio - Imageslider Docs |
e upper right corner, "minimal" only shows the runtime display, "hidden"
shows 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 o... | Event Listeners | https://gradio.app/docs/gradio/imageslider | Gradio - Imageslider Docs |
nt
is the return value of another components .click method. Functions that have
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 "onc... | Event Listeners | https://gradio.app/docs/gradio/imageslider | Gradio - Imageslider Docs |
radio client libraries), or "undocumented" (hidden
from API docs but callable 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 | ... | Event Listeners | https://gradio.app/docs/gradio/imageslider | Gradio - Imageslider Docs |
Creates a set of checkboxes. Can be used as an input to pass a set of
values to a function or as an output to display values, a subset of which are
selected.
| Description | https://gradio.app/docs/gradio/checkboxgroup | Gradio - Checkboxgroup Docs |
**Using CheckboxGroup as an input component.**
How CheckboxGroup will pass its value to your function:
Type: `list[str | int | float] | list[int | None]`
Passes the list of checked checkboxes as a `list[str | int | float]` or their indices as a `list[int]` into the function, depending on `type`.
Example Code
... | Behavior | https://gradio.app/docs/gradio/checkboxgroup | Gradio - Checkboxgroup Docs |
Parameters ▼
choices: list[str | int | float | tuple[str, str | int | float]] | None
default `= None`
A list of string or numeric options to select from. An option can also be a
tuple of the form (name, value), where name is the displayed name of the
checkbox button and value is the value to be passed... | Initialization | https://gradio.app/docs/gradio/checkboxgroup | Gradio - Checkboxgroup Docs |
nt] | 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 display label.
show_select_all: bool
def... | Initialization | https://gradio.app/docs/gradio/checkboxgroup | Gradio - Checkboxgroup Docs |
None`
An optional list of strings that are assigned as the classes of this component
in the HTML DOM. Can be used for targeting CSS styles.
render: bool
default `= True`
If False, component will not render be rendered in the Blocks context. Should
be used if the intention is to assign event listener... | Initialization | https://gradio.app/docs/gradio/checkboxgroup | Gradio - Checkboxgroup Docs |
Shortcuts
gradio.CheckboxGroup
Interface String Shortcut `"checkboxgroup"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/checkboxgroup | Gradio - Checkboxgroup Docs |
sentence_builder
| Demos | https://gradio.app/docs/gradio/checkboxgroup | Gradio - Checkboxgroup 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 CheckboxGroup component supports the fo... | Event Listeners | https://gradio.app/docs/gradio/checkboxgroup | Gradio - Checkboxgroup Docs |
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 | BlockContext | list[Component | BlockContext] | Set[Component | BlockContext] | None
default `= None`
List of gradio.components to us... | Event Listeners | https://gradio.app/docs/gradio/checkboxgroup | Gradio - Checkboxgroup Docs |
ol
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, will use the queue setting of the gradio app.
batch: bool
default `= False`
If True, then the function should ... | Event Listeners | https://gradio.app/docs/gradio/checkboxgroup | Gradio - Checkboxgroup Docs |
)`) 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()` events) would allow a second submission after the
pending event is complete.
js: str | Literal[True] | None
de... | Event Listeners | https://gradio.app/docs/gradio/checkboxgroup | Gradio - Checkboxgroup Docs |
ne`
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: Callable | None
default `= None`
Optional validation function to run before the main function. If provided,
this function wi... | Event Listeners | https://gradio.app/docs/gradio/checkboxgroup | Gradio - Checkboxgroup Docs |
The gr.RetryData class is a subclass of gr.Event data that specifically
carries information about the `.retry()` event. When gr.RetryData is added as
a type hint to an argument of an event listener method, a gr.RetryData object
will automatically be passed as the value of that argument. The attributes of
this object co... | Description | https://gradio.app/docs/gradio/retrydata | Gradio - Retrydata Docs |
import gradio as gr
def retry(retry_data: gr.RetryData, history: list[gr.MessageDict]):
history_up_to_retry = history[:retry_data.index]
new_response = ""
for token in api.chat_completion(history):
new_response += token
yield history + [new_response]
wit... | Example Usage | https://gradio.app/docs/gradio/retrydata | Gradio - Retrydata Docs |
Parameters ▼
index: int | tuple[int, int]
The index of the user message that should be retried.
value: Any
The value of the user message that should be retried.
[Chatbot Specific Events](../../guides/chatbot-specific-events/)
| Attributes | https://gradio.app/docs/gradio/retrydata | Gradio - Retrydata Docs |
The Dependency object is usually not created directly but is returned when
an event listener is set up. It contains the configuration data for the event
listener, and can be used to set up additional event listeners that depend on
the completion of the current event listener using .then(), .success(), and
.failure(). ... | Description | https://gradio.app/docs/gradio/dependency | Gradio - Dependency Docs |
import gradio as gr
with gr.Blocks() as demo:
first_textbox = gr.Textbox()
second_textbox = gr.Textbox()
button = gr.Button("Submit")
dependency = button.click(lambda x: "Hello, " + x, first_textbox, second_textbox)
dependency.success(lambda: gr.Info("Greeting succ... | Example Usage | https://gradio.app/docs/gradio/dependency | Gradio - Dependency Docs |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.