1. Helpers
  2. Dependency

New to Gradio? Start here: Getting Started

See the Release History

Dependency

Description

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().

Example Usage

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 successful"), None, None)
    dependency.failure(lambda: gr.Warning("Greeting failed"), None, None)

demo.launch()

Demos