How can i use tabs as an input?

I’m creating some tabs and when i click a button i want to use the name of the tabs as an input for a function. How does it work? Thank you very much!

My way of creating tabs would be for example this, with blocks:

with gr.Tabs() as tabs:
                with gr.TabItem("test1"):
                    bt_test1 = gr.Button('test1')
                with gr.TabItem("test2"):   
                    bt_test2 = gr.Button('test2')

You can use the select() event listener that TabItem (which also has the alias Tab) supports:

import gradio as gr

with gr.Blocks() as demo:
    with gr.Tabs():
        with gr.Tab("hi") as hi:
        with gr.Tab("hello") as hello:
    output = gr.Textbox() :"hi", None, output) :"hello", None, output) 
1 Like