Spaces:
Sleeping
Sleeping
File size: 1,446 Bytes
cc5f090 df37867 cc5f090 df37867 cc5f090 df37867 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
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()
|