gradio/demo/tabs_visibility/run.py
Hannah 61cd768490
Ensures tabs with visible set to false are not visible. (#9653)
* * fix tab visibility
* add story

* add changeset

* stuff

* fix

* more fix

* fix undefined tab labels

* fix tabs again

* add changeset

* format

* format

* fix type

* add changeset

* fix all things

* format

* add changeset

* notebooks

* visible tabs

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: pngwn <hello@pngwn.io>
Co-authored-by: freddyaboulton <alfonsoboulton@gmail.com>
2024-10-21 16:46:01 -07:00

37 lines
951 B
Python

import gradio as gr
with gr.Blocks() as demo:
with gr.Tab("abc"):
gr.Textbox(label="abc")
with gr.Tab("def", visible=False) as t:
gr.Textbox(label="def")
with gr.Tab("ghi"):
gr.Textbox(label="ghi")
with gr.Tab("jkl", visible=False) as t2:
gr.Textbox(label="jkl")
with gr.Tab("mno"):
gr.Textbox(label="mno")
with gr.Tab("pqr", visible=False) as t3:
gr.Textbox(label="pqr")
with gr.Tab("stu"):
gr.Textbox(label="stu")
with gr.Tab("vwx", visible=False) as t4:
gr.Textbox(label="vwx")
with gr.Tab("yz"):
gr.Textbox(label="yz")
b = gr.Button("Make visible")
b.click(
lambda: [
gr.Tab(visible=True),
gr.Tab(visible=True),
gr.Tab(visible=True),
gr.Tab(visible=True),
],
inputs=None,
outputs=[t, t2, t3, t4],
)
if __name__ == "__main__":
demo.launch()