Closed vzakharov closed 8 months ago
I don't think this is documented but if you use the full version of Tab instead of the shorthand then you can achieve this behaviour:
import gradio as gr
with gr.Blocks() as demo:
with gr.Tabs() as tabs:
with gr.TabItem("Tab 1"):
...
with gr.TabItem("Tab 2"):
...
in this example tabs
can be used as an output to an event and you can set the visible state. This will hide the whole tabbed interface, hiding an individual tab is not currently possible due to how tabs actually work. But we could try to make this work.
It’s good to know the full version, but yeah it doesn’t achieve the intended effect. Thanks for giving this a thought!
Any updates on this one?
Not yet, the team has other competing priorities so it's likely we won't be able to get to this anytime soon. PRs are welcome!
@abidlabs Yes, this has also been issue for me, hard to control gr.TabItem for specific flexible startup modes. So I just end up with dummy tab that has nothing in it, which is bad looking.
I don't think this is documented but if you use the full version of Tab instead of the shorthand then you can achieve this behaviour:
import gradio as gr with gr.Blocks() as demo: with gr.Tabs() as tabs: with gr.TabItem("Tab 1"): ... with gr.TabItem("Tab 2"): ...
in this example
tabs
can be used as an output to an event and you can set the visible state. This will hide the whole tabbed interface, hiding an individual tab is not currently possible due to how tabs actually work. But we could try to make this work.
This works for me! (I only need to hide a tab, and never need to show it.) the codess are as follows:
with gr.Tabs(visible=False) as tabs:
with gr.Tab('hide page'):
...
This is a glaring issue if the recommended way to create a variable number of components is to create dummy ones and hide them.
Good to know about the gr.Tabs visibility approach, although for my use case, it could get pretty complicated. My use case is to have a user profile that specifies which application tabs are displayed for a specific user. I could implement this with the gr.Tabs visibility, but given that I have 5+ tabs, that could result in upwards of 5 x 5 gr.Tabs "Templates" to turn the visibility on/off.....I am wondering if it would be possible to dynamically generate the set of tabs from individual "tab templates"? Thoughts anyone?
Currently
gr.Tab
doesn’t seem to have avisible
parameter, unlike most other components. This makes it impossible to hide a Tab depending on certain conditionsSay, in my Jukebox Web UI this could be hiding or showing “continue composing” tab depending on whether or not the very first sample has already been generated.
I wonder if it’s possible to add such a parameter?