Spaces:
Runtime error
Runtime error
Commit ·
670df4a
1
Parent(s): f6e11f0
new
Browse files
app.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import pandas as pd
|
| 3 |
-
from apscheduler.schedulers.background import BackgroundScheduler
|
| 4 |
|
| 5 |
# Initialize an empty to-do list DataFrame
|
| 6 |
TODO_COLUMNS = ["Task", "Priority", "Status"]
|
|
@@ -9,8 +8,9 @@ todo_df = pd.DataFrame(columns=TODO_COLUMNS)
|
|
| 9 |
# Function to add a new task
|
| 10 |
def add_task(task, priority, status):
|
| 11 |
global todo_df
|
| 12 |
-
|
| 13 |
-
|
|
|
|
| 14 |
return todo_df
|
| 15 |
|
| 16 |
# Function to delete a task by index
|
|
@@ -25,51 +25,47 @@ def get_tasks():
|
|
| 25 |
return todo_df
|
| 26 |
|
| 27 |
# Initialize Gradio app
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
with demo:
|
| 31 |
gr.Markdown("# 📝 Personal To-Do List Tracker")
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
)
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
priority_input = gr.Dropdown(
|
| 45 |
-
choices=["Low", "Medium", "High"],
|
| 46 |
-
label="Priority",
|
| 47 |
-
value="Medium"
|
| 48 |
-
)
|
| 49 |
-
status_input = gr.Dropdown(
|
| 50 |
-
choices=["Not Started", "In Progress", "Completed"],
|
| 51 |
-
label="Status",
|
| 52 |
-
value="Not Started"
|
| 53 |
-
)
|
| 54 |
-
add_button = gr.Button("Add Task")
|
| 55 |
-
add_button.click(
|
| 56 |
-
add_task,
|
| 57 |
-
inputs=[task_input, priority_input, status_input],
|
| 58 |
-
outputs=task_table,
|
| 59 |
-
)
|
| 60 |
-
|
| 61 |
-
with gr.TabItem("🗑️ Delete Task"):
|
| 62 |
-
delete_index = gr.Number(label="Task Index to Delete", value=0)
|
| 63 |
-
delete_button = gr.Button("Delete Task")
|
| 64 |
-
delete_button.click(
|
| 65 |
-
delete_task,
|
| 66 |
-
inputs=delete_index,
|
| 67 |
-
outputs=task_table,
|
| 68 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
| 73 |
|
| 74 |
# Launch the Gradio app
|
| 75 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import pandas as pd
|
|
|
|
| 3 |
|
| 4 |
# Initialize an empty to-do list DataFrame
|
| 5 |
TODO_COLUMNS = ["Task", "Priority", "Status"]
|
|
|
|
| 8 |
# Function to add a new task
|
| 9 |
def add_task(task, priority, status):
|
| 10 |
global todo_df
|
| 11 |
+
if task: # Ensure task is not empty
|
| 12 |
+
new_task = pd.DataFrame([[task, priority, status]], columns=TODO_COLUMNS)
|
| 13 |
+
todo_df = pd.concat([todo_df, new_task], ignore_index=True)
|
| 14 |
return todo_df
|
| 15 |
|
| 16 |
# Function to delete a task by index
|
|
|
|
| 25 |
return todo_df
|
| 26 |
|
| 27 |
# Initialize Gradio app
|
| 28 |
+
with gr.Blocks() as demo:
|
|
|
|
|
|
|
| 29 |
gr.Markdown("# 📝 Personal To-Do List Tracker")
|
| 30 |
|
| 31 |
+
task_table = gr.Dataframe(
|
| 32 |
+
value=get_tasks(),
|
| 33 |
+
headers=TODO_COLUMNS,
|
| 34 |
+
interactive=False,
|
| 35 |
+
label="Current Tasks",
|
| 36 |
+
max_rows=10
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
# Add Task Section
|
| 40 |
+
with gr.Row():
|
| 41 |
+
task_input = gr.Textbox(label="Task", placeholder="Enter your task here")
|
| 42 |
+
priority_input = gr.Dropdown(
|
| 43 |
+
choices=["Low", "Medium", "High"],
|
| 44 |
+
label="Priority",
|
| 45 |
+
value="Medium"
|
| 46 |
)
|
| 47 |
+
status_input = gr.Dropdown(
|
| 48 |
+
choices=["Not Started", "In Progress", "Completed"],
|
| 49 |
+
label="Status",
|
| 50 |
+
value="Not Started"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
)
|
| 52 |
+
add_button = gr.Button("Add Task")
|
| 53 |
+
|
| 54 |
+
add_button.click(
|
| 55 |
+
fn=add_task,
|
| 56 |
+
inputs=[task_input, priority_input, status_input],
|
| 57 |
+
outputs=task_table
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
# Delete Task Section
|
| 61 |
+
delete_index = gr.Number(label="Task Index to Delete", value=0)
|
| 62 |
+
delete_button = gr.Button("Delete Task")
|
| 63 |
|
| 64 |
+
delete_button.click(
|
| 65 |
+
fn=delete_task,
|
| 66 |
+
inputs=delete_index,
|
| 67 |
+
outputs=task_table
|
| 68 |
+
)
|
| 69 |
|
| 70 |
# Launch the Gradio app
|
| 71 |
demo.launch()
|