Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| def enable_second_task(secret): | |
| if secret == "lol": | |
| return [ | |
| gr.Textbox.update(visible=False), | |
| gr.Button.update(visible=False), | |
| gr.Textbox.update(visible=True), | |
| gr.Textbox.update(visible=True), | |
| gr.Button.update(visible=True) | |
| ] | |
| return [ | |
| gr.Textbox.update(visible=True), | |
| gr.Button.update(visible=True), | |
| gr.Textbox.update(visible=False), | |
| gr.Textbox.update(visible=False), | |
| gr.Button.update(visible=False) | |
| ] | |
| def greet(name): | |
| return "Hello " + name + "!!" | |
| demo = gr.Demo() | |
| with demo: | |
| secret_textbox = gr.Textbox( | |
| placeholder="secret", label="Secret", show_label=True | |
| ) | |
| secret_button = gr.Button("Submit") | |
| name_textbox = gr.Textbox( | |
| placeholder="Name", label="Name", show_label=True, visible=False | |
| ) | |
| greet_textbox = gr.Textbox( | |
| placeholder="", label="Output", show_label=True, visible=False | |
| ) | |
| greet_button = gr.Button("Greet", visible=False) | |
| submit_button.click( | |
| enable_second_task, | |
| secret_textbox, | |
| [secret_textbox, secret_button, name_textbox, greet_textbox, greet_button] | |
| ) | |
| greet_button.click(greet, name_textbox, greet_textbox) | |
| demo.launch() | |