Download app.py from hmb/tabs_test: direct link, hf CLI and curl.
- Browser
- Download file 2.07 kB
-
https://huggingface.co/spaces/hmb/tabs_test/resolve/main/app.py
- Command line
-
hf download hf://spaces/hmb/tabs_test/app.py
-
curl -L -o app.py https://huggingface.co/spaces/hmb/tabs_test/resolve/main/app.py
2.07 kB
| import gradio as gr | |
| with gr.Blocks() as demo: | |
| with gr.Row(): | |
| def change_to_tab_two(): | |
| return gr.Tabs(selected=2) #This will navigate | |
| 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]) # This does navigate | |
| with gr.Row(): | |
| def change_to_tab_two(): | |
| return gr.Tabs(selected=2), gr.Tab(label="New tab two label") #This won't navigate | |
| 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]) #This doesn't navigate | |
| demo.launch() | |