Spaces:
Running
Running
Add 1 files
Browse files
app.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
def todo_list(title, description, priority):
|
4 |
+
# Add task to the list
|
5 |
+
task = {}
|
6 |
+
task["title"] = title
|
7 |
+
task["description"] = description
|
8 |
+
task["priority"] = priority
|
9 |
+
|
10 |
+
# Render the output table with the task list
|
11 |
+
output = []
|
12 |
+
output.append(["Title", "Description", "Priority"])
|
13 |
+
for item in taskList:
|
14 |
+
output.append([item["title"], item["description"], item["priority"]])
|
15 |
+
output = gr.Response(gr.Scrollable(), output)
|
16 |
+
return output
|
17 |
+
|
18 |
+
def clear_list():
|
19 |
+
# Clear the task list
|
20 |
+
global taskList
|
21 |
+
taskList = []
|
22 |
+
|
23 |
+
# Update the output table with the task list
|
24 |
+
output = []
|
25 |
+
output.append(["Title", "Description", "Priority"])
|
26 |
+
output = gr.Response(gr.Scrollable(), output)
|
27 |
+
return output
|
28 |
+
|
29 |
+
# Initialize the task list
|
30 |
+
taskList = []
|
31 |
+
|
32 |
+
# Start the app
|
33 |
+
todo_app = gr.Interface(
|
34 |
+
todo_list,
|
35 |
+
[
|
36 |
+
gr.Textbox(label="Title"),
|
37 |
+
gr.Textbox(label="Description"),
|
38 |
+
gr.Select(label="Priority", options=["High", "Medium", "Low"])
|
39 |
+
],
|
40 |
+
[
|
41 |
+
gr.Button("Add Task"),
|
42 |
+
gr.Button("Clear List")
|
43 |
+
],
|
44 |
+
[gr.Scrollable()]
|
45 |
+
)
|
46 |
+
|
47 |
+
todo_app.launch()
|