text stringlengths 0 2k | heading1 stringlengths 3 79 | source_page_url stringclasses 190
values | source_page_title stringclasses 190
values |
|---|---|---|---|
e 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 | None | Literal[False]
default `= None`
Description of the API endpoint. Can be... | Event Listeners | https://gradio.app/docs/gradio/state | Gradio - State Docs |
. 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 inputs to batch together if this is called from the queue
(only relevant if ba... | Event Listeners | https://gradio.app/docs/gradio/state | Gradio - State Docs |
as arguments; raw code can access them through `arguments`. Return a list of
values for the 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 None to mean no con... | Event Listeners | https://gradio.app/docs/gradio/state | Gradio - State Docs |
main function be called. The validator
receives the same inputs as the main function, including the same keyword
arguments when `inputs_kwargs` is used, so its signature must accept those
keyword names. It should return a `gr.validate()` for each input value.
inputs_kwargs: dict[str, Component | BlockCo... | Event Listeners | https://gradio.app/docs/gradio/state | Gradio - State Docs |
This function allows you to pass custom warning messages to the user. You
can do so simply by writing `gr.Warning('message here')` in your function, and
when that line is executed the custom message will appear in a modal on the
demo. The modal is yellow by default and has the heading: "Warning." Queue
must be enabled ... | Description | https://gradio.app/docs/gradio/warning | Gradio - Warning Docs |
import gradio as gr
def hello_world():
gr.Warning('This is a warning message.')
return "hello world"
with gr.Blocks() as demo:
md = gr.Markdown()
demo.load(hello_world, inputs=None, outputs=[md])
demo.queue().launch()
| Example Usage | https://gradio.app/docs/gradio/warning | Gradio - Warning Docs |
Parameters ▼
message: str
default `= "Warning issued."`
The warning message to be displayed to the user. Can be HTML, which will be
rendered in the modal.
duration: float | None
default `= 10`
The duration in seconds that the warning message should be displayed for. If
None or 0, the... | Initialization | https://gradio.app/docs/gradio/warning | Gradio - Warning Docs |
blocks_chained_events
[Alerts](../../guides/alerts)
| Demos | https://gradio.app/docs/gradio/warning | Gradio - Warning Docs |
This class allows you to pass custom error messages to the user. You can do
so by raising a gr.Error("custom message") anywhere in the code, and when that
line is executed the custom message will appear in a modal on the demo.
You can control for how long the error message is displayed with the
`duration` parameter. I... | Description | https://gradio.app/docs/gradio/error | Gradio - Error Docs |
import gradio as gr
def divide(numerator, denominator):
if denominator == 0:
raise gr.Error("Cannot divide by zero!")
gr.Interface(divide, ["number", "number"], "number").launch()
| Example Usage | https://gradio.app/docs/gradio/error | Gradio - Error Docs |
Parameters ▼
message: str
default `= "Error raised."`
The error message to be displayed to the user. Can be HTML, which will be
rendered in the modal.
duration: float | None
default `= 10`
The duration in seconds to display the error message. If None or 0, the error
message will be d... | Initialization | https://gradio.app/docs/gradio/error | Gradio - Error Docs |
calculatorblocks_chained_events
[Alerts](../../guides/alerts/)
| Demos | https://gradio.app/docs/gradio/error | Gradio - Error Docs |
A Gradio Interface includes a ‘Flag’ button that appears underneath the
output. By default, clicking on the Flag button sends the input and output
data back to the machine where the gradio demo is running, and saves it to a
CSV log file. But this default behavior can be changed. To set what happens
when the Flag button... | Description | https://gradio.app/docs/gradio/flagging | Gradio - Flagging Docs |
A simplified implementation of the FlaggingCallback abstract class provided
for illustrative purposes. Each flagged sample (both the input and output
data) is logged to a CSV file on the machine running the gradio app.
| Description | https://gradio.app/docs/gradio/flagging | Gradio - Flagging Docs |
import gradio as gr
def image_classifier(inp):
return {'cat': 0.3, 'dog': 0.7}
demo = gr.Interface(fn=image_classifier, inputs="image", outputs="label",
flagging_callback=SimpleCSVLogger())
CSVLogger
gradio.CSVLogger(···)
| Example Usage | https://gradio.app/docs/gradio/flagging | Gradio - Flagging Docs |
The default implementation of the FlaggingCallback abstract class in
gradio>=5.0. Each flagged sample (both the input and output data) is logged to
a CSV file with headers on the machine running the gradio app. Unlike
ClassicCSVLogger, this implementation is concurrent-safe and it creates a new
dataset file every time ... | Description | https://gradio.app/docs/gradio/flagging | Gradio - Flagging Docs |
import gradio as gr
def image_classifier(inp):
return {'cat': 0.3, 'dog': 0.7}
demo = gr.Interface(fn=image_classifier, inputs="image", outputs="label",
flagging_callback=CSVLogger())
| Example Usage | https://gradio.app/docs/gradio/flagging | Gradio - Flagging Docs |
Parameters ▼
simplify_file_data: bool
default `= True`
If True, the file data will be simplified before being written to the CSV
file. If CSVLogger is being used to cache examples, this is set to False to
preserve the original FileData class
verbose: bool
default `= True`
If True, pr... | Initialization | https://gradio.app/docs/gradio/flagging | Gradio - Flagging 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 |
ore 'fn', provided as either a function
or a raw code string. A function receives the values of 'inputs' and 'outputs'
as arguments; raw code can access them through `arguments`. Return a list of
values for the output components.
concurrency_limit: int | None | Literal['default']
default `= "default"`
... | Event Listeners | https://gradio.app/docs/gradio/downloadbutton | Gradio - Downloadbutton Docs |
on. 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, including the same keyword
arguments when `inputs_kwargs` is used, so its signature must accept those
keyword names... | Event Listeners | https://gradio.app/docs/gradio/downloadbutton | Gradio - Downloadbutton 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 |
The gr.KeyUpData class is a subclass of gr.EventData that specifically
carries information about the `.key_up()` event. When gr.KeyUpData is added as
a type hint to an argument of an event listener method, a gr.KeyUpData object
will automatically be passed as the value of that argument. The attributes of
this object co... | Description | https://gradio.app/docs/gradio/keyupdata | Gradio - Keyupdata Docs |
import gradio as gr
def test(value, key_up_data: gr.KeyUpData):
return {
"component value": value,
"input value": key_up_data.input_value,
"key": key_up_data.key
}
with gr.Blocks() as demo:
d = gr.Dropdown(["abc", "def"], allow_custom_value=T... | Example Usage | https://gradio.app/docs/gradio/keyupdata | Gradio - Keyupdata Docs |
Parameters ▼
key: str
The key that was pressed.
input_value: str
The displayed value in the input textbox after the key was pressed. This may
be different than the `value` attribute of the component itself, as the
`value` attribute of some components (e.g. Dropdown) are not updated unt... | Attributes | https://gradio.app/docs/gradio/keyupdata | Gradio - Keyupdata Docs |
dropdown_key_up
| Demos | https://gradio.app/docs/gradio/keyupdata | Gradio - Keyupdata Docs |
Decorator that auto-caches function results based on content-hashed inputs.
Works with sync/async functions and sync/async generators. For generators, all
yielded values are cached and replayed on hit. Cache hits bypass the Gradio
queue. It can also be called at runtime as `gr.cache(fn)(*args)` to cache
intermediate he... | Description | https://gradio.app/docs/gradio/cache | Gradio - Cache Docs |
import gradio as gr
@gr.cache
def classify(image):
return model.predict(image)
@gr.cache(max_size=256, per_session=True)
def generate(prompt):
return llm(prompt)
| Example Usage | https://gradio.app/docs/gradio/cache | Gradio - Cache Docs |
Parameters ▼
fn: Callable | None
default `= None`
The function to cache. When used as @gr.cache without parentheses, this is the
decorated function. When used as @gr.cache(...), this is None. When used as
`gr.cache(fn)(...)`, this must be a callable.
key: Callable | None
default `= No... | Initialization | https://gradio.app/docs/gradio/cache | Gradio - Cache Docs |
Creates a "Sign In" button that redirects the user to sign in with Hugging
Face OAuth. Once the user is signed in, the button will act as a logout
button, and you can retrieve a signed-in user's profile by adding a parameter
of type `gr.OAuthProfile` to any Gradio function. This will only work if this
Gradio app is run... | Description | https://gradio.app/docs/gradio/loginbutton | Gradio - Loginbutton Docs |
**Using LoginButton as an input component.**
How LoginButton 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 | N... | Behavior | https://gradio.app/docs/gradio/loginbutton | Gradio - Loginbutton Docs |
Parameters ▼
value: str
default `= "Sign in with Hugging Face"`
logout_value: str
default `= "Logout ({})"`
The text to display when the user is signed in. The string should contain a
placeholder for the username with a call-to-action to logout, e.g. "Logout
({})".
eve... | Initialization | https://gradio.app/docs/gradio/loginbutton | Gradio - Loginbutton Docs |
Shortcuts
gradio.LoginButton
Interface String Shortcut `"loginbutton"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/loginbutton | Gradio - Loginbutton Docs |
login_with_huggingface
| Demos | https://gradio.app/docs/gradio/loginbutton | Gradio - Loginbutton 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 LoginButton component supports the foll... | Event Listeners | https://gradio.app/docs/gradio/loginbutton | Gradio - Loginbutton 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_descr... | Event Listeners | https://gradio.app/docs/gradio/loginbutton | Gradio - Loginbutton Docs |
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
default `= 4`
Ma... | Event Listeners | https://gradio.app/docs/gradio/loginbutton | Gradio - Loginbutton Docs |
her a function
or a raw code string. A function receives the values of 'inputs' and 'outputs'
as arguments; raw code can access them through `arguments`. Return a list of
values for the output components.
concurrency_limit: int | None | Literal['default']
default `= "default"`
If set, this is the maxi... | Event Listeners | https://gradio.app/docs/gradio/loginbutton | Gradio - Loginbutton Docs |
ction 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, including the same keyword
arguments when `inputs_kwargs` is used, so its signature must accept those
keyword names. It should return a `gr.... | Event Listeners | https://gradio.app/docs/gradio/loginbutton | Gradio - Loginbutton Docs |
The gr.LikeData class is a subclass of gr.EventData that specifically
carries information about the `.like()` event. When gr.LikeData is added as a
type hint to an argument of an event listener method, a gr.LikeData object
will automatically be passed as the value of that argument. The attributes of
this object contain... | Description | https://gradio.app/docs/gradio/likedata | Gradio - Likedata Docs |
import gradio as gr
def test(value, like_data: gr.LikeData):
return {
"chatbot_value": value,
"liked_message": like_data.value,
"liked_index": like_data.index,
"liked_or_disliked_as_bool": like_data.liked
}
with gr.Blocks() as demo:
... | Example Usage | https://gradio.app/docs/gradio/likedata | Gradio - Likedata Docs |
Parameters ▼
index: int | tuple[int, int]
The index of the liked/disliked item. Is a tuple if the component is two
dimensional.
value: Any
The value of the liked/disliked item.
liked: bool
True if the item was liked, False if disliked, or string value if any other
feed... | Attributes | https://gradio.app/docs/gradio/likedata | Gradio - Likedata Docs |
chatbot_core_components_simple
[Chatbot Specific Events](../../guides/chatbot-specific-events/)
| Demos | https://gradio.app/docs/gradio/likedata | Gradio - Likedata 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 |
s
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 ... | Initialization | https://gradio.app/docs/gradio/code | Gradio - Code Docs |
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 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 |
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 |
nce. 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 assi... | 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 |
docs and callable by clients), "private" (hidden from API docs
and not callable by the Gradio 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... | Event Listeners | https://gradio.app/docs/gradio/imageslider | Gradio - Imageslider 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 JavaScript to run before 'fn', provided as either a function
or a raw code string. A function receives the values of 'inputs' and 'outputs'
as arguments; raw code can access them through `arguments`. Return a list of
values for the output components.
concurrency_limit: int | None | Literal['default'... | Event Listeners | https://gradio.app/docs/gradio/datetime | Gradio - Datetime Docs |
un 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, including the same keyword
arguments when `inputs_kwargs` is used, so its signature must a... | Event Listeners | https://gradio.app/docs/gradio/datetime | Gradio - Datetime 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 |
Shortcuts
gradio.BarPlot
Interface String Shortcut `"barplot"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/barplot | Gradio - Barplot Docs |
bar_plot_demo
| Demos | https://gradio.app/docs/gradio/barplot | Gradio - Barplot 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 BarPlot component supports the followin... | Event Listeners | https://gradio.app/docs/gradio/barplot | Gradio - Barplot Docs |
nents 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 should... | Event Listeners | https://gradio.app/docs/gradio/barplot | Gradio - Barplot Docs |
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 a li... | Event Listeners | https://gradio.app/docs/gradio/barplot | Gradio - Barplot Docs |
. 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 JavaScript to run before 'f... | Event Listeners | 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.