Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query request: Does Gradio allow to bind a click on another component event in the click function of a Button? #4411

Closed
Kilig947 opened this issue Jun 3, 2023 · 1 comment

Comments

@Kilig947
Copy link

Kilig947 commented Jun 3, 2023

  • [ yes] I have searched to see if a similar issue already exists.

Is your feature request related to a problem? Please describe.
I would like to implement in my application that after filling out a form and clicking the button to submit, it switches to a new Tab and displays the contents of my form, but I've checked the API and asked OPENAI and both tell me that I can't do this

Describe the solution you'd like
with gr.Column(scale=100): # If the component is drawn under a layout element, it will be displayed according to the layout element's rules
gr.Markdown('# Here is column 1')
with gr.Tab(label='test1') as tab1_col.
chatbot = gr.Chatbot().style(height=400)
status = gr.Markdown()
with gr.Tab(label='test2', id='tab2') as tab2_col.
chatbot2 = gr.Chatbot().style(height=400)
status2 = gr.Markdown()

    with gr.Column(scale=30, elem_id='xixi').
        # gr.Markdown('# Here is column 2')
        i_say = gr.Textbox()
        submit = gr.Button(value='submit', variant='primary')
        switch = gr.Button(value='submit', variant='stop', elem_id='switch_button')
        with gr.
            you_say = gr.Textbox(show_label=False, placeholder='No output box of any use')
            Noo = gr.Button(value='No button of any use')

demo as above, I want the page to switch from gr.Tab(label='test1') to gr.Tab(label='test2' after clicking the switch button and show my submitted content (trigger) the select event of tab2_col

Translated with www.DeepL.com/Translator (free version)

Additional context
Add any other context or screenshots about the feature request here.

@Kilig947 Kilig947 changed the title 疑问请求:Gradio 是否允许在Button的click函数中绑定一个点击另外的组件事件? Query request: Does Gradio allow to bind a click on another component event in the click function of a Button? Jun 3, 2023
@abidlabs
Copy link
Member

abidlabs commented Jun 3, 2023

Hi @Kilig947 yes, you can submit your form and then update the selected tab by returning gr.Tabs.update(select=) from your function. You can see an example of this here: #2412 (comment)

@abidlabs abidlabs closed this as completed Jun 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants