File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments