Skip to content

Commit ef537b7

Browse files
authored
Create gui.py
1 parent 12c6f03 commit ef537b7

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

taskspark/gui.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import tkinter as tk
2+
from task_manager import load_tasks, add_task, complete_task, save_tasks
3+
4+
root = tk.Tk()
5+
root.title("TaskSpark GUI")
6+
7+
frame = tk.Frame(root)
8+
frame.pack(padx=20, pady=20)
9+
10+
tasks = load_tasks()
11+
12+
def refresh():
13+
for widget in frame.winfo_children():
14+
widget.destroy()
15+
for i, task in enumerate(tasks):
16+
status = "✅" if task["completed"] else "❌"
17+
color = "#34d399" if task["priority"] <=2 else "#fbbf24" if task["priority"]==3 else "#f87171"
18+
btn = tk.Button(frame, text=f"{status} {task['title']}", bg=color, command=lambda i=i: complete(i))
19+
btn.pack(fill="x", pady=2)
20+
21+
def complete(index):
22+
tasks[index]["completed"] = True
23+
save_tasks(tasks)
24+
refresh()
25+
26+
refresh()
27+
root.mainloop()

0 commit comments

Comments
 (0)