archerlinn commited on
Commit
9a8af44
·
1 Parent(s): 8db7e82
Files changed (1) hide show
  1. app.py +5 -88
app.py CHANGED
@@ -1,45 +1,5 @@
1
  import gradio as gr
2
- import pandas as pd
3
- from datetime import datetime
4
-
5
- # Initialize an empty to-do list DataFrame
6
- TODO_COLUMNS = ["Task", "Priority", "Status", "Due Date"]
7
- todo_df = pd.DataFrame(columns=TODO_COLUMNS)
8
-
9
- # Function to add a new task
10
- def add_task(task, priority, status, due_date):
11
- global todo_df
12
- try:
13
- # Validate date format
14
- due_date = datetime.strptime(due_date, "%Y-%m-%d").strftime("%Y-%m-%d")
15
- except ValueError:
16
- return todo_df # Skip adding if date is invalid
17
-
18
- if task.strip():
19
- new_task = pd.DataFrame([[task, priority, status, due_date]], columns=TODO_COLUMNS)
20
- todo_df = pd.concat([todo_df, new_task], ignore_index=True)
21
- todo_df = sort_tasks(todo_df)
22
- return todo_df
23
-
24
- # Function to delete a task by index
25
- def delete_task(index):
26
- global todo_df
27
- if 0 <= index < len(todo_df):
28
- todo_df = todo_df.drop(index).reset_index(drop=True)
29
- todo_df = sort_tasks(todo_df)
30
- return todo_df
31
-
32
- # Function to get the current list of tasks
33
- def get_tasks():
34
- return sort_tasks(todo_df)
35
-
36
- # Function to sort tasks by priority and due date
37
- def sort_tasks(df):
38
- priority_order = {"High": 0, "Medium": 1, "Low": 2}
39
- df["Priority Rank"] = df["Priority"].map(priority_order)
40
- df["Due Date"] = pd.to_datetime(df["Due Date"], errors="coerce")
41
- df = df.sort_values(by=["Priority Rank", "Due Date"]).drop(columns=["Priority Rank"]).reset_index(drop=True)
42
- return df
43
 
44
  # Initialize Gradio app with dark tech-inspired theme
45
  with gr.Blocks() as demo:
@@ -53,7 +13,7 @@ with gr.Blocks() as demo:
53
 
54
  # Create an empty DataFrame display
55
  task_table = gr.DataFrame(
56
- headers=TODO_COLUMNS,
57
  label="Current Tasks",
58
  elem_id="task-table",
59
  interactive=False
@@ -115,52 +75,9 @@ with gr.Blocks() as demo:
115
  outputs=task_table
116
  )
117
 
118
- # Custom CSS for Futuristic Tech Style
119
- custom_css = """
120
- body {
121
- background-color: #181818;
122
- color: #E0E0E0;
123
- font-family: 'Roboto Mono', monospace;
124
- }
125
- #task-table {
126
- background-color: #1f1f1f;
127
- color: #E0E0E0;
128
- border: 1px solid #FFA500;
129
- border-radius: 8px;
130
- }
131
- #input-box {
132
- background-color: #1c1c1c;
133
- color: #E0E0E0;
134
- border: 1px solid #FFA500;
135
- border-radius: 8px;
136
- padding: 10px;
137
- }
138
- #dropdown {
139
- background-color: #1c1c1c;
140
- color: #E0E0E0;
141
- border: 1px solid #FFA500;
142
- border-radius: 8px;
143
- padding: 5px;
144
- }
145
- #button {
146
- background-color: #FFA500;
147
- color: #181818;
148
- border: none;
149
- border-radius: 8px;
150
- padding: 10px 20px;
151
- font-weight: bold;
152
- box-shadow: 0 0 12px #FF8C00;
153
- transition: all 0.2s ease-in-out;
154
- }
155
- #button:hover {
156
- background-color: #FF8C00;
157
- color: #FFFFFF;
158
- box-shadow: 0 0 16px #FFA500;
159
- }
160
- """
161
-
162
- # Apply custom CSS
163
- demo.css = custom_css
164
 
165
  # Launch the Gradio app
166
  demo.launch()
 
1
  import gradio as gr
2
+ from task_functions import add_task, delete_task, get_tasks
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  # Initialize Gradio app with dark tech-inspired theme
5
  with gr.Blocks() as demo:
 
13
 
14
  # Create an empty DataFrame display
15
  task_table = gr.DataFrame(
16
+ headers=["Task", "Priority", "Status", "Due Date"],
17
  label="Current Tasks",
18
  elem_id="task-table",
19
  interactive=False
 
75
  outputs=task_table
76
  )
77
 
78
+ # Load external CSS file
79
+ with open("styles.css", "r") as f:
80
+ demo.css = f.read()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
  # Launch the Gradio app
83
  demo.launch()