Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
"""
|
2 |
-
This is a simple todo list app that allows you to
|
3 |
All actions are performed on the client side.
|
4 |
"""
|
5 |
import gradio as gr
|
6 |
|
7 |
tasks = ["Get a job", "Marry rich", "", "", "", ""]
|
8 |
textboxes = []
|
9 |
-
|
10 |
with gr.Blocks() as demo:
|
11 |
with gr.Row():
|
12 |
with gr.Column(scale=3):
|
@@ -20,9 +20,13 @@ with gr.Blocks() as demo:
|
|
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 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
27 |
|
28 |
-
|
|
|
|
1 |
"""
|
2 |
+
This is a simple todo list app that allows you to edit tasks and mark tasks as complete.
|
3 |
All actions are performed on the client side.
|
4 |
"""
|
5 |
import gradio as gr
|
6 |
|
7 |
tasks = ["Get a job", "Marry rich", "", "", "", ""]
|
8 |
textboxes = []
|
9 |
+
buttons = []
|
10 |
with gr.Blocks() as demo:
|
11 |
with gr.Row():
|
12 |
with gr.Column(scale=3):
|
|
|
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 |
+
buttons.append(b)
|
24 |
+
t.change(lambda : gr.Button(interactive=True, variant="primary"), None, b, js=True)
|
25 |
+
b.click(lambda : gr.Row(visible=False), None, r, js=True)
|
26 |
+
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)
|
27 |
+
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)
|
28 |
+
freeze_button.click(lambda : [gr.Button(visible=False), gr.Button(visible=False), gr.Button(visible=False), gr.Button(visible=False), gr.Button(visible=False), gr.Button(visible=False)], None, buttons, js=True)
|
29 |
+
edit_button.click(lambda : [gr.Button(visible=True), gr.Button(visible=True), gr.Button(visible=True), gr.Button(visible=True), gr.Button(visible=True), gr.Button(visible=True)], None, buttons, js=True)
|
30 |
|
31 |
+
if __name__ == "__main__":
|
32 |
+
demo.launch()
|