| | import gradio as gr |
| |
|
| | with gr.Blocks() as demo: |
| | with gr.Row(): |
| | def change_to_tab_two(): |
| | return gr.Tabs(selected=2) |
| |
|
| | with gr.Tabs() as tabs: |
| | with gr.Tab(id=1, label="Tab 1", visible=True, interactive=True) as tab_one: |
| | tab_one_tbox = gr.Textbox(label="Tab One Textbox") |
| | tab_one_btn = gr.Button(value="Change Tab (shouldn't navigate)") |
| | with gr.Tab(id=2, label="Tab 2", visible=True, interactive=False) as tab_two: |
| | tab_two_tbox = gr.Textbox(label="Tab Two Textbox") |
| | tab_one_btn.click(fn=change_to_tab_two,inputs=None, outputs=[tabs]) |
| |
|
| | with gr.Row(): |
| | def change_to_tab_two(): |
| | return gr.Tabs(selected=2), gr.Tab(label="New tab two label") |
| |
|
| | with gr.Tabs() as tabs: |
| | with gr.Tab(id=1, label="Tab 1", visible=True, interactive=True) as tab_one: |
| | tab_one_tbox = gr.Textbox(label="Tab One Textbox") |
| | tab_one_btn = gr.Button(value="Change Tab (should navigate)") |
| | with gr.Tab(id=2, label="Tab 2", visible=True, interactive=True) as tab_two: |
| | tab_two_tbox = gr.Textbox(label="Tab Two Textbox") |
| | tab_one_btn.click(fn=change_to_tab_two, inputs=None, outputs=[tabs, tab_two]) |
| |
|
| | with gr.Row(): |
| | def change_to_tab_two(): |
| | return gr.Tabs(selected=2), gr.Textbox(label="Textbox two new label") |
| |
|
| | with gr.Tabs() as tabs: |
| | with gr.Tab(id=1, label="Tab 1", visible=True, interactive=True) as tab_one: |
| | tab_one_tbox = gr.Textbox(label="Tab One Textbox") |
| | tab_one_btn = gr.Button(value="Change Tab (should navigate)") |
| | with gr.Tab(id=2, label="Tab 2", visible=True, interactive=True) as tab_two: |
| | tab_two_tbox = gr.Textbox(label="Tab Two Textbox",interactive=False) |
| | tab_one_btn.click(fn=change_to_tab_two, inputs=None, outputs=[tabs, tab_two_tbox]) |
| |
|
| | demo.launch() |
| |
|