Closed coolboyqu closed 6 months ago
try this
import gradio as gr
def change_tab(id):
return gr.Tabs(selected=id)
with gr.Blocks() as demo:
with gr.Tabs() as tabs:
with gr.TabItem("Train", id=0): #index is 0
t = gr.Textbox()
with gr.TabItem("Inference", id=1): #index is 1
i = gr.Image()
btn = gr.Button()
# When the button is clicked, switch to Tab1 (index 1)
btn.click(change_tab, gr.Number(1, visible=False), tabs)
demo.launch()
Thanks @mussonero! Yes that's the correct approach for selecting tabs programmatically
For example, if I choose Tab4 now, I would like to select Tab1 by clicking on a button or something else. Does Gradio currently have similar features?