Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,6 @@ import gradio as gr
|
|
6 |
|
7 |
tasks = ["Get a job", "Marry rich", "", "", "", ""]
|
8 |
textboxes = []
|
9 |
-
rows = []
|
10 |
|
11 |
with gr.Blocks() as demo:
|
12 |
with gr.Row():
|
@@ -14,17 +13,17 @@ with gr.Blocks() as demo:
|
|
14 |
gr.Markdown("# A Simple Interactive Todo List")
|
15 |
with gr.Column(scale=2):
|
16 |
with gr.Row():
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
|
29 |
# Add a button to add a new task
|
30 |
|
|
|
6 |
|
7 |
tasks = ["Get a job", "Marry rich", "", "", "", ""]
|
8 |
textboxes = []
|
|
|
9 |
|
10 |
with gr.Blocks() as demo:
|
11 |
with gr.Row():
|
|
|
13 |
gr.Markdown("# A Simple Interactive Todo List")
|
14 |
with gr.Column(scale=2):
|
15 |
with gr.Row():
|
16 |
+
freeze_button = gr.Button("Freeze tasks", variant="stop")
|
17 |
+
edit_button = gr.Button("Edit tasks")
|
18 |
+
for i in range(6):
|
19 |
+
with gr.Row() as r:
|
20 |
+
t = gr.Textbox(tasks[i], placeholder="Enter a task", show_label=False, container=False, scale=7, interactive=True)
|
21 |
+
b = gr.Button("✔️", interactive=bool(tasks[i]), variant="primary" if tasks[i] else "secondary")
|
22 |
+
textboxes.append(t)
|
23 |
+
t.change(lambda : gr.Button(interactive=True, variant="primary"), None, b, js=True)
|
24 |
+
b.click(lambda : gr.Row(visible=False), None, r, js=True)
|
25 |
+
freeze_button.click(lambda : [gr.Textbox(interactive=False), gr.Textbox(interactive=False), gr.Textbox(interactive=False), gr.Textbox(interactive=False), gr.Textbox(interactive=False), gr.Textbox(interactive=False)], None, textboxes, js=True)
|
26 |
+
edit_button.click(lambda : [gr.Textbox(interactive=True), gr.Textbox(interactive=True), gr.Textbox(interactive=True), gr.Textbox(interactive=True), gr.Textbox(interactive=True), gr.Textbox(interactive=True)], None, textboxes, js=True)
|
27 |
|
28 |
# Add a button to add a new task
|
29 |
|