text stringlengths 0 2k | heading1 stringlengths 3 79 | source_page_url stringclasses 189
values | source_page_title stringclasses 189
values |
|---|---|---|---|
esponds 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 `= None`
List of gr... | collapse | https://gradio.app/docs/gradio/accordion | Gradio - Accordion Docs |
mation 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 place the reque... | collapse | https://gradio.app/docs/gradio/accordion | Gradio - Accordion Docs |
r 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 while an event ... | collapse | https://gradio.app/docs/gradio/accordion | Gradio - Accordion Docs |
ia 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 listener to be use... | collapse | https://gradio.app/docs/gradio/accordion | Gradio - Accordion Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | expand | https://gradio.app/docs/gradio/accordion | Gradio - Accordion Docs |
c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%... | expand | https://gradio.app/docs/gradio/accordion | Gradio - Accordion Docs |
onds 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 `= None`
List of gradi... | expand | https://gradio.app/docs/gradio/accordion | Gradio - Accordion Docs |
ion 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 place the request ... | expand | https://gradio.app/docs/gradio/accordion | Gradio - Accordion Docs |
enerators 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 while an event is ... | expand | https://gradio.app/docs/gradio/accordion | Gradio - Accordion Docs |
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 listener to be used i... | expand | https://gradio.app/docs/gradio/accordion | Gradio - Accordion Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | collapse | https://gradio.app/docs/gradio/accordion | Gradio - Accordion Docs |
%3c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.... | collapse | https://gradio.app/docs/gradio/accordion | Gradio - Accordion Docs |
esponds 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 `= None`
List of gr... | collapse | https://gradio.app/docs/gradio/accordion | Gradio - Accordion Docs |
mation 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 place the reque... | collapse | https://gradio.app/docs/gradio/accordion | Gradio - Accordion Docs |
r 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 while an event ... | collapse | https://gradio.app/docs/gradio/accordion | Gradio - Accordion Docs |
ia 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 listener to be use... | collapse | https://gradio.app/docs/gradio/accordion | Gradio - Accordion Docs |
ChatInterface is Gradio's high-level abstraction for creating chatbot UIs,
and allows you to create a web-based demo around a chatbot model in a few
lines of code. Only one parameter is required: fn, which takes a function that
governs the response of the chatbot based on the user input and chat history.
Additional par... | Description | https://gradio.app/docs/gradio/chatinterface | Gradio - Chatinterface Docs |
**Basic Example** : A chatbot that echoes back the users’s message
import gradio as gr
def echo(message, history):
return message
demo = gr.ChatInterface(fn=echo, examples=["hello", "hola", "merhaba"], title="Echo Bot")
demo.launch()
**Custom Chatbot** : A `gr.ChatInterface... | Example Usage | https://gradio.app/docs/gradio/chatinterface | Gradio - Chatinterface Docs |
Parameters ▼
fn: Callable
the function to wrap the chat interface around. The function should accept two parameters: a `str` representing the input message and `list` of openai-style dictionaries: {"role": "user" | "assistant", "content": `str` | {"path": `str`} | `gr.Component`} representing the chat ... | Initialization | https://gradio.app/docs/gradio/chatinterface | Gradio - Chatinterface Docs |
cks, then the components will be
displayed under the chatbot, in an accordion. The values of these components
will be passed into `fn` as arguments in order after the chat history.
additional_inputs_accordion: str | Accordion | None
default `= None`
if a string is provided, this is the label of the `g... | Initialization | https://gradio.app/docs/gradio/chatinterface | Gradio - Chatinterface Docs |
atbot.
example_labels: list[str] | None
default `= None`
labels for the examples, to be displayed instead of the examples themselves.
If provided, should be a list of strings with the same length as the examples
list. Only applies when examples are displayed within the chatbot (i.e. when
`additional_i... | Initialization | https://gradio.app/docs/gradio/chatinterface | Gradio - Chatinterface Docs |
None`
a title for the interface; if provided, appears above chatbot in large font.
Also used as the tab title when opened in a browser window.
description: str | None
default `= None`
a description for the interface; if provided, appears above the chatbot and
beneath the title in regular font. Accept... | Initialization | https://gradio.app/docs/gradio/chatinterface | Gradio - Chatinterface Docs |
tton with a submit icon within the textbox. If a
string, will use that string as the submit button text in place of the icon.
If False, will not show a submit button.
stop_btn: str | bool | None
default `= True`
If True, will show a button with a stop icon during generator executions, to
stop generati... | Initialization | https://gradio.app/docs/gradio/chatinterface | Gradio - Chatinterface Docs |
hat interface will expand to the height of window.
fill_width: bool
default `= False`
Whether to horizontally expand to fill container fully. If False, centers and
constrains app to a maximum width.
api_name: str | None
default `= None`
defines how the chat endpoint appears in the AP... | Initialization | https://gradio.app/docs/gradio/chatinterface | Gradio - Chatinterface Docs |
chatinterface_random_responsechatinterface_streaming_echochatinterface_artifacts
[Creating A Chatbot Fast](../../guides/creating-a-chatbot-fast/)[Chatinterface
Examples](../../guides/chatinterface-examples/)[Agents And Tool
Usage](../../guides/agents-and-tool-usage/)[Chatbot Specific
Events](../../guides/chatbot-speci... | Demos | https://gradio.app/docs/gradio/chatinterface | Gradio - Chatinterface Docs |
Row is a layout element within Blocks that renders all children
horizontally.
| Description | https://gradio.app/docs/gradio/row | Gradio - Row Docs |
with gr.Blocks() as demo:
with gr.Row():
gr.Image("lion.jpg", scale=2)
gr.Image("tiger.jpg", scale=1)
demo.launch()
| Example Usage | https://gradio.app/docs/gradio/row | Gradio - Row Docs |
Parameters ▼
variant: Literal['default', 'panel', 'compact']
default `= "default"`
row type, 'default' (no background), 'panel' (gray background color and
rounded corners), or 'compact' (rounded corners and no internal gap).
visible: bool | Literal['hidden']
default `= True`
If False... | Initialization | https://gradio.app/docs/gradio/row | Gradio - Row Docs |
is
smaller than `max_height`.
min_height: int | str | None
default `= None`
The minimum height of the row, specified in pixels if a number is passed, or
in CSS units if a string is passed. If content exceeds the height, the row
will expand to fit the content. Will not have any effect if `height` is s... | Initialization | https://gradio.app/docs/gradio/row | Gradio - Row Docs |
The widths of elements in a `Row` can be controlled via a combination of
`scale` and `min_width` arguments that are present in every component.
* `scale` is an integer that defines how an element will take up space in a `Row`. If `scale` is set to 0, the element will not expand to take up space. If `scale` is set to... | Controlling Width | https://gradio.app/docs/gradio/row | Gradio - Row Docs |
Creates a Dialogue component for displaying or collecting multi-speaker
conversations. This component can be used as input to allow users to enter
dialogue involving multiple speakers, or as output to display diarized speech,
such as the result of a transcription or speaker identification model. Each
message can be ass... | Description | https://gradio.app/docs/gradio/dialogue | Gradio - Dialogue Docs |
**Using Dialogue as an input component.**
How Dialogue will pass its value to your function:
Type: `str | list[dict[str, str]]`
Returns the dialogue as a string or list of dictionaries.
Example Code
import gradio as gr
def predict(
value: str | list[dict[str, str... | Behavior | https://gradio.app/docs/gradio/dialogue | Gradio - Dialogue Docs |
Parameters ▼
value: list[dict[str, str]] | Callable | None
default `= None`
Value of the dialogue. It is a list of dictionaries, each containing a
'speaker' key and a 'text' key. If a function is provided, the function will
be called each time the app loads to set the initial value of this component.
... | Initialization | https://gradio.app/docs/gradio/dialogue | Gradio - Dialogue Docs |
tor: str
default `= " "`
The separator between the different dialogue lines used to join the formatted
dialogue lines into a single string. It should be unambiguous. For example, a
newline character or tab character.
color_map: dict[str, str] | None
default `= None`
A dictionary mapping speaker name... | Initialization | https://gradio.app/docs/gradio/dialogue | Gradio - Dialogue Docs |
um 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 | None
default `= None`
if True, will be rendered as an editable textbox;... | Initialization | https://gradio.app/docs/gradio/dialogue | Gradio - Dialogue Docs |
identity across a re-render. Components
that have the same key across a re-render will have their value preserved.
max_lines: int | None
default `= None`
maximum number of lines allowed in the dialogue.
buttons: list[Literal['copy'] | Button] | None
default `= None`
A list of buttons... | Initialization | https://gradio.app/docs/gradio/dialogue | Gradio - Dialogue Docs |
Shortcuts
gradio.Dialogue
Interface String Shortcut `"dialogue"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/dialogue | Gradio - Dialogue Docs |
dia_dialogue_demo
| Demos | https://gradio.app/docs/gradio/dialogue | Gradio - Dialogue 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 Dialogue component supports the followi... | Event Listeners | https://gradio.app/docs/gradio/dialogue | Gradio - Dialogue Docs |
et[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 a string, the... | Event Listeners | https://gradio.app/docs/gradio/dialogue | Gradio - Dialogue Docs |
pp.
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 tuple of lists... | Event Listeners | https://gradio.app/docs/gradio/dialogue | Gradio - Dialogue Docs |
fter 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.
concurrency_limit: in... | Event Listeners | https://gradio.app/docs/gradio/dialogue | Gradio - Dialogue Docs |
nal 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 input value.
| Event Listeners | https://gradio.app/docs/gradio/dialogue | Gradio - Dialogue Docs |
Any code in a `if gr.NO_RELOAD` code-block will not be re-evaluated when
the source file is reloaded. This is helpful for importing modules that do not
like to be reloaded (tiktoken, numpy) as well as database connections and long
running set up code.
| Description | https://gradio.app/docs/gradio/NO_RELOAD | Gradio - No_Reload Docs |
import gradio as gr
if gr.NO_RELOAD:
from transformers import pipeline
pipe = pipeline("text-classification", model="cardiffnlp/twitter-roberta-base-sentiment-latest")
gr.Interface.from_pipeline(pipe).launch()
| Example Usage | https://gradio.app/docs/gradio/NO_RELOAD | Gradio - No_Reload Docs |
Creates a line plot component to display data from a pandas DataFrame.
| Description | https://gradio.app/docs/gradio/lineplot | Gradio - Lineplot Docs |
**Using LinePlot as an input component.**
How LinePlot will pass its value to your function:
Type: `PlotData | None`
The data to display in a line plot.
Example Code
import gradio as gr
def predict(
value: PlotData | None
):
process value from... | Behavior | https://gradio.app/docs/gradio/lineplot | Gradio - Lineplot Docs |
Parameters ▼
value: pd.DataFrame | Callable | None
default `= None`
The pandas dataframe containing the data to display in the plot.
x: str | None
default `= None`
Column corresponding to the x axis. Column can be numeric, datetime, or
string/category.
y: str | None
... | Initialization | https://gradio.app/docs/gradio/lineplot | Gradio - Lineplot Docs |
ne`
List containing column names of the series to show in the legend. By default,
all series are shown.
x_lim: list[float | None] | None
default `= None`
A tuple or list containing the limits for the x-axis, specified as [x_min,
x_max]. To fix only one of these values, set the other to None, e.g. [0,... | Initialization | https://gradio.app/docs/gradio/lineplot | Gradio - Lineplot Docs |
", "-x", "-y", or list of strings that represent the order of the
categories.
tooltip: Literal['axis', 'none', 'all'] | list[str]
default `= "axis"`
The tooltip to display when hovering on a point. "axis" shows the values for
the axis columns, "all" shows all column values, and "none" shows no tooltip... | Initialization | https://gradio.app/docs/gradio/lineplot | Gradio - Lineplot Docs |
uts: 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.
visible: bool | Literal['hidden']
default `= True`
Whether the plo... | Initialization | https://gradio.app/docs/gradio/lineplot | Gradio - Lineplot Docs |
-render.
preserved_by_key: list[str] | str | None
default `= "value"`
A list of parameters from this component's constructor. Inside a gr.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 ... | Initialization | https://gradio.app/docs/gradio/lineplot | Gradio - Lineplot Docs |
`gr.LinePlot`, `gr.ScatterPlot`, and `gr.BarPlot` all share the same API. Here
is a summary of the most important features. For full details and live demos,
see the [Creating Plots](/guides/creating-plots) and [Time
Plots](/guides/time-plots) guides.
**Basic Usage with a DataFrame**
Pass a `pd.DataFrame` as the value... | Key Concepts | https://gradio.app/docs/gradio/lineplot | Gradio - Lineplot Docs |
ex[0], selection.index[1]])
plot.double_click(lambda: gr.LinePlot(x_lim=None), outputs=plot)
**Realtime Data**
Use `gr.Timer` to keep plots updated with live data. You can attach the timer
via `every`, or wire it up manually:
def get_data():
return pd.DataFrame(...) fetch latest d... | Key Concepts | https://gradio.app/docs/gradio/lineplot | Gradio - Lineplot Docs |
Shortcuts
gradio.LinePlot
Interface String Shortcut `"lineplot"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/lineplot | Gradio - Lineplot Docs |
line_plot_demo
| Demos | https://gradio.app/docs/gradio/lineplot | Gradio - Lineplot 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 LinePlot component supports the followi... | Event Listeners | https://gradio.app/docs/gradio/lineplot | Gradio - Lineplot Docs |
omponents 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 use as outputs. If the function returns no
outputs, this sh... | Event Listeners | https://gradio.app/docs/gradio/lineplot | Gradio - Lineplot Docs |
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 process a batch of inputs, meaning that it
should accept ... | Event Listeners | https://gradio.app/docs/gradio/lineplot | Gradio - Lineplot Docs |
ding. 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
default `= None`
Optional frontend js method to run before... | Event Listeners | https://gradio.app/docs/gradio/lineplot | Gradio - Lineplot Docs |
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 will be executed first with queue=False, and only if it
com... | Event Listeners | https://gradio.app/docs/gradio/lineplot | Gradio - Lineplot Docs |
Load a chat interface from an OpenAI API chat compatible endpoint.
| Description | https://gradio.app/docs/gradio/load_chat | Gradio - Load_Chat Docs |
import gradio as gr
demo = gr.load_chat("http://localhost:11434/v1", model="deepseek-r1")
demo.launch()
| Example Usage | https://gradio.app/docs/gradio/load_chat | Gradio - Load_Chat Docs |
Parameters ▼
base_url: str
The base URL of the endpoint, e.g. "http://localhost:11434/v1/"
model: str
The name of the model you are loading, e.g. "llama3.2"
token: str | None
default `= None`
The API token or a placeholder string if you are using a local model, e.g.
"... | Initialization | https://gradio.app/docs/gradio/load_chat | Gradio - Load_Chat Docs |
Column is a layout element within Blocks that renders all children
vertically. The widths of columns can be set through the `scale` and
`min_width` parameters. If a certain scale results in a column narrower than
min_width, the min_width parameter will win.
| Description | https://gradio.app/docs/gradio/column | Gradio - Column Docs |
with gr.Blocks() as demo:
with gr.Row():
with gr.Column(scale=1):
text1 = gr.Textbox()
text2 = gr.Textbox()
with gr.Column(scale=4):
btn1 = gr.Button("Button 1")
btn2 = gr.Button("Button 2")
| Example Usage | https://gradio.app/docs/gradio/column | Gradio - Column Docs |
Parameters ▼
scale: int
default `= 1`
relative width compared to adjacent Columns. For example, if Column A has
scale=2, and Column B has scale=1, A will be twice as wide as B.
min_width: int
default `= 320`
minimum pixel width of Column, will wrap if not sufficient screen space to
s... | Initialization | https://gradio.app/docs/gradio/column | Gradio - Column Docs |
ved_by_key: list[str] | str | None
default `= None`
A list of parameters from this component's constructor. Inside a gr.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... | Initialization | https://gradio.app/docs/gradio/column | Gradio - Column Docs |
Creates a checkbox that can be set to `True` or `False`. Can be used as an
input to pass a boolean value to a function or as an output to display a
boolean value.
| Description | https://gradio.app/docs/gradio/checkbox | Gradio - Checkbox Docs |
**Using Checkbox as an input component.**
How Checkbox will pass its value to your function:
Type: `bool | None`
Passes the status of the checkbox as a `bool`.
Example Code
import gradio as gr
def predict(
value: bool | None
):
process value f... | Behavior | https://gradio.app/docs/gradio/checkbox | Gradio - Checkbox Docs |
Parameters ▼
value: bool | Callable
default `= False`
if True, checked by default. 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 label for this checkbox, dis... | Initialization | https://gradio.app/docs/gradio/checkbox | Gradio - Checkbox Docs |
ue results in this Component being narrower than
min_width, the min_width parameter will be respected first.
interactive: bool | None
default `= None`
if True, this checkbox can be checked; if False, checking will be disabled. If
not provided, this is inferred based on whether the component is used as... | Initialization | https://gradio.app/docs/gradio/checkbox | Gradio - Checkbox Docs |
ues
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 their configured
icon and/or label, and clicking them will trigger any .click() events
registe... | Initialization | https://gradio.app/docs/gradio/checkbox | Gradio - Checkbox Docs |
Shortcuts
gradio.Checkbox
Interface String Shortcut `"checkbox"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/checkbox | Gradio - Checkbox Docs |
sentence_builderhello_world_3
| Demos | https://gradio.app/docs/gradio/checkbox | Gradio - Checkbox 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 Checkbox component supports the followi... | Event Listeners | https://gradio.app/docs/gradio/checkbox | Gradio - Checkbox Docs |
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 use as outputs. If the function returns no
outp... | Event Listeners | https://gradio.app/docs/gradio/checkbox | Gradio - Checkbox Docs |
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 process a batch of inputs, meaning that it
sh... | Event Listeners | https://gradio.app/docs/gradio/checkbox | Gradio - Checkbox Docs |
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
default `= None`
Optional frontend js method t... | Event Listeners | https://gradio.app/docs/gradio/checkbox | Gradio - Checkbox Docs |
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 will be executed first with queue=False, and on... | Event Listeners | https://gradio.app/docs/gradio/checkbox | Gradio - Checkbox Docs |
Creates a button, that when clicked, allows a user to download a single
file of arbitrary type.
| Description | https://gradio.app/docs/gradio/downloadbutton | Gradio - Downloadbutton Docs |
**Using DownloadButton as an input component.**
How DownloadButton will pass its value to your function:
Type: `str | None`
(Rarely used) passes the file as a `str` into the function.
Example Code
import gradio as gr
def predict(
value: str | None
):
... | Behavior | https://gradio.app/docs/gradio/downloadbutton | Gradio - Downloadbutton Docs |
Parameters ▼
label: str
default `= "Download"`
Text to display on the button. Defaults to "Download".
value: str | Path | Callable | None
default `= None`
A str or pathlib.Path filepath or URL to download, or a Callable that returns
a str or pathlib.Path filepath or URL to download.
... | Initialization | https://gradio.app/docs/gradio/downloadbutton | Gradio - Downloadbutton Docs |
ents
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_width parameter will be respected first.
... | Initialization | https://gradio.app/docs/gradio/downloadbutton | Gradio - Downloadbutton Docs |
Shortcuts
gradio.DownloadButton
Interface String Shortcut `"downloadbutton"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/downloadbutton | Gradio - Downloadbutton Docs |
upload_and_download
| Demos | https://gradio.app/docs/gradio/downloadbutton | Gradio - Downloadbutton 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 DownloadButton component supports the f... | Event Listeners | https://gradio.app/docs/gradio/downloadbutton | Gradio - Downloadbutton Docs |
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 used as the API
endpoint.
... | Event Listeners | https://gradio.app/docs/gradio/downloadbutton | Gradio - Downloadbutton Docs |
t 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.
max_batch_siz... | Event Listeners | https://gradio.app/docs/gradio/downloadbutton | Gradio - Downloadbutton Docs |
re 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 running
simultaneously. Ca... | Event Listeners | https://gradio.app/docs/gradio/downloadbutton | Gradio - Downloadbutton Docs |
ompletes 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/downloadbutton | Gradio - Downloadbutton Docs |
Creates a bar plot component to display data from a pandas DataFrame.
| Description | https://gradio.app/docs/gradio/barplot | Gradio - Barplot Docs |
**Using BarPlot as an input component.**
How BarPlot will pass its value to your function:
Type: `PlotData | None`
The data to display in a line plot.
Example Code
import gradio as gr
def predict(
value: PlotData | None
):
process value from t... | Behavior | https://gradio.app/docs/gradio/barplot | Gradio - Barplot Docs |
Parameters ▼
value: pd.DataFrame | Callable | None
default `= None`
The pandas dataframe containing the data to display in the plot.
x: str | None
default `= None`
Column corresponding to the x axis. Column can be numeric, datetime, or
string/category.
y: str | None
... | Initialization | https://gradio.app/docs/gradio/barplot | Gradio - Barplot Docs |
ne`
List containing column names of the series to show in the legend. By default,
all series are shown.
x_lim: list[float | None] | None
default `= None`
A tuple or list containing the limits for the x-axis, specified as [x_min,
x_max]. To fix only one of these values, set the other to None, e.g. [0,... | Initialization | https://gradio.app/docs/gradio/barplot | Gradio - Barplot Docs |
", "-x", "-y", or list of strings that represent the order of the
categories.
tooltip: Literal['axis', 'none', 'all'] | list[str]
default `= "axis"`
The tooltip to display when hovering on a point. "axis" shows the values for
the axis columns, "all" shows all column values, and "none" shows no tooltip... | Initialization | https://gradio.app/docs/gradio/barplot | Gradio - Barplot Docs |
uts: 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.
visible: bool | Literal['hidden']
default `= True`
Whether the plo... | Initialization | https://gradio.app/docs/gradio/barplot | Gradio - Barplot Docs |
-render.
preserved_by_key: list[str] | str | None
default `= "value"`
A list of parameters from this component's constructor. Inside a gr.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 ... | Initialization | https://gradio.app/docs/gradio/barplot | Gradio - Barplot Docs |
`gr.LinePlot`, `gr.ScatterPlot`, and `gr.BarPlot` all share the same API. Here
is a summary of the most important features. For full details and live demos,
see the [Creating Plots](/guides/creating-plots) and [Time
Plots](/guides/time-plots) guides.
**Basic Usage with a DataFrame**
Pass a `pd.DataFrame` as the value... | Key Concepts | https://gradio.app/docs/gradio/barplot | Gradio - Barplot Docs |
ection: gr.SelectData):
return gr.BarPlot(x_lim=[selection.index[0], selection.index[1]])
plot.double_click(lambda: gr.BarPlot(x_lim=None), outputs=plot)
**Realtime Data**
Use `gr.Timer` to keep plots updated with live data. You can attach the timer
via `every`, or wire it up manually:
... | Key Concepts | https://gradio.app/docs/gradio/barplot | Gradio - Barplot Docs |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.