0

For example, I have following mini app :

import gradio as gr

def processing1(text):
    return "result1", "result2"
    
def send():
    pass

def processing2(text):
    return "result3"

tab1 = gr.Blocks()
with tab1:
    with gr.Row():
        with gr.Column():
            input_text = gr.TextArea(label="Input Text", placeholder="Paste your text here")
            submit_btn = gr.Button("submit")
        with gr.Column():
            output_text1 = gr.TextArea(label="Output Text")
            output_text2 = gr.TextArea(label="Output Text2")
            send_btn = gr.Button("send to tab2")
    submit_btn.click(processing1, inputs=[input_text], outputs=[output_text1, output_text2])
    send_btn.click(send)

tab2 = gr.Blocks()
with tab2:
    with gr.Row():
        with gr.Column():
            input_text2 = gr.TextArea(label="Input Text", placeholder="Paste your text here")
            checkbox1 = gr.Checkbox(label="checkbox1")
            checkbox2 = gr.Checkbox(label="checkbox2")
            submit_btn2 = gr.Button("submit")
        with gr.Column():
            output_text3 = gr.TextArea(label="Output Text")

    submit_btn2.click(processing2, inputs=input_text2, outputs=output_text3)

demo = gr.TabbedInterface([tab1, tab2], tab_names=["tab1", "tab2"])
demo.launch()

I want send the output of tab1 (here is the “result2”) to the input of tab2(here is the input_text2) and active the tab2 as current tab, how to achieve this ?

Wade Wang
  • 536
  • 6
  • 11

0 Answers0