Updating tab labels in gradio

429 views Asked by At

Gradio is an excellent tool for making interfaces, especially for fast prototyping with sufficient flexibility. I can programmatically update the labels of buttons, dropdown menus, and almost all the components, including Akkordeon, but not tabs!

The following code would update the label of any element (textbox chosen for the example) but not of the tab).

import gradio as gr
import numpy as np

def update_tab_name():
    new_tab = gr.Tab('My Tab with a new Tab')
    new_element = gr.Textbox('Some new random text: %s' % str(np.random.random()))
    return new_tab, new_element


with gr.Blocks() as demo:
    my_tab = gr.Tab('My Tab')
    with my_tab:
        gr.HTML('Hello world')
        other_element = gr.Textbox('Some text', container=False)
    my_button = gr.Button('My Button')
    my_button.click(fn=update_tab_name, outputs=[my_tab, other_element])

demo.launch()

Is there any workaround to make the update of gr.Tab() labels working in gradio?

0

There are 0 answers