Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,47 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def greet(name):
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
textbox = gr.Textbox(
|
7 |
-
placeholder="secret", label="Secret", show_label=True, visible=False
|
8 |
-
)
|
9 |
def enable_second_task(secret):
|
10 |
if secret == "lol":
|
11 |
-
return
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
|
|
|
|
3 |
|
|
|
|
|
|
|
4 |
def enable_second_task(secret):
|
5 |
if secret == "lol":
|
6 |
+
return [
|
7 |
+
gr.Textbox.update(visible=False),
|
8 |
+
gr.Button.update(visible=False),
|
9 |
+
gr.Textbox.update(visible=True),
|
10 |
+
gr.Textbox.update(visible=True),
|
11 |
+
gr.Button.update(visible=True)
|
12 |
+
]
|
13 |
+
return [
|
14 |
+
gr.Textbox.update(visible=True),
|
15 |
+
gr.Button.update(visible=True),
|
16 |
+
gr.Textbox.update(visible=False),
|
17 |
+
gr.Textbox.update(visible=False),
|
18 |
+
gr.Button.update(visible=False)
|
19 |
+
]
|
20 |
|
21 |
+
def greet(name):
|
22 |
+
return "Hello " + name + "!!"
|
23 |
|
24 |
+
demo = gr.Demo()
|
25 |
+
with demo:
|
26 |
+
secret_textbox = gr.Textbox(
|
27 |
+
placeholder="secret", label="Secret", show_label=True
|
28 |
+
)
|
29 |
+
secret_button = gr.Button("Submit")
|
30 |
+
|
31 |
+
name_textbox = gr.Textbox(
|
32 |
+
placeholder="Name", label="Name", show_label=True, visible=False
|
33 |
+
)
|
34 |
+
greet_textbox = gr.Textbox(
|
35 |
+
placeholder="", label="Output", show_label=True, visible=False
|
36 |
+
)
|
37 |
+
greet_button = gr.Button("Greet", visible=False)
|
38 |
+
|
39 |
+
|
40 |
+
submit_button.click(
|
41 |
+
enable_second_task,
|
42 |
+
secret_textbox,
|
43 |
+
[secret_textbox, secret_button, name_textbox, greet_textbox, greet_button]
|
44 |
+
)
|
45 |
+
greet_button.click(greet, name_textbox, greet_textbox)
|
46 |
+
|
47 |
+
demo.launch()
|