|
1 | 1 | import tkinter as tk |
2 | | - |
3 | 2 | from core.utils.file_utils import sessions_exist, get_projects |
4 | 3 |
|
5 | 4 | class MainWindow(tk.Frame): |
6 | 5 | def __init__(self, parent, controller, logic_controller): |
7 | | - tk.Frame.__init__(self, parent) |
8 | | - self.controller = controller # GUI controller |
9 | | - self.logic = logic_controller |
| 6 | + super().__init__(parent) |
| 7 | + self.controller = controller |
10 | 8 | self.logic = logic_controller |
11 | 9 |
|
12 | 10 | # Check if we have projects or sessions |
13 | 11 | _ = get_projects() |
14 | 12 | _ = sessions_exist() |
15 | | - |
16 | 13 |
|
| 14 | + # Title Label |
17 | 15 | label_text = "Track app usage in a project or standalone session." |
18 | | - |
19 | | - label = tk.Label(self, text=label_text) |
20 | | - label.pack(side="top", fill="x", pady=10) |
21 | | - |
22 | | - # Start new session button |
23 | | - button1 = tk.Button(self, text="Start new session", |
24 | | - command=lambda: self.controller.show_frame("CreateSessionWindow"), width=25) |
25 | | - button1.pack(pady=3) |
26 | | - |
27 | | - # Project management button |
28 | | - button_projects = tk.Button(self, text="Projects", |
29 | | - command=lambda: self.controller.show_frame("ProjectsWindow"), width=25) |
30 | | - button_projects.pack(pady=3) |
31 | | - |
32 | | - # Sessions button (always show) |
33 | | - button2 = tk.Button(self, text="Sessions", |
34 | | - command=lambda: [self.controller.show_frame("SessionsWindow"), self.logic.app_tracker.start_filter_reset(refresh=True)], width=25) |
35 | | - button2.pack(pady=3) |
36 | | - |
37 | | - # Configure custom rules button |
38 | | - button3 = tk.Button(self, text="Configure custom rules", |
39 | | - command=lambda: self.controller.show_frame("TrackerSettingsWindow"), |
40 | | - width=25) |
41 | | - button3.pack(pady=3) |
42 | | - |
43 | | - exit_button = tk.Button(self, text=" Exit ", command=lambda: self.controller.on_close()) |
44 | | - exit_button.pack(pady=10, side='bottom') |
| 16 | + label = tk.Label(self, text=label_text, font=("Arial", 14, "bold")) |
| 17 | + label.pack(side="top", pady=(15, 20)) |
| 18 | + |
| 19 | + # Button Container |
| 20 | + button_frame = tk.Frame(self) |
| 21 | + button_frame.pack(pady=10) |
| 22 | + |
| 23 | + # Row 1: Sessions + Projects |
| 24 | + btn_session = tk.Button( |
| 25 | + button_frame, text="Start New Session", |
| 26 | + command=lambda: self.controller.show_frame("CreateSessionWindow"), |
| 27 | + width=20, height=2 |
| 28 | + ) |
| 29 | + btn_session.grid(row=0, column=0, padx=10, pady=10) |
| 30 | + |
| 31 | + btn_projects = tk.Button( |
| 32 | + button_frame, text="Projects", |
| 33 | + command=lambda: self.controller.show_frame("ProjectsWindow"), |
| 34 | + width=20, height=2 |
| 35 | + ) |
| 36 | + btn_projects.grid(row=0, column=1, padx=10, pady=10) |
| 37 | + |
| 38 | + # Row 2: Sessions list + Rules |
| 39 | + btn_sessions = tk.Button( |
| 40 | + button_frame, text="View Sessions", |
| 41 | + command=lambda: [ |
| 42 | + self.controller.show_frame("SessionsWindow"), |
| 43 | + self.logic.app_tracker.start_filter_reset(refresh=True) |
| 44 | + ], |
| 45 | + width=20, height=2 |
| 46 | + ) |
| 47 | + btn_sessions.grid(row=1, column=0, padx=10, pady=10) |
| 48 | + |
| 49 | + btn_rules = tk.Button( |
| 50 | + button_frame, text="Custom Rules", |
| 51 | + command=lambda: self.controller.show_frame("TrackerSettingsWindow"), |
| 52 | + width=20, height=2 |
| 53 | + ) |
| 54 | + btn_rules.grid(row=1, column=1, padx=10, pady=10) |
| 55 | + |
| 56 | + # Exit Button at Bottom |
| 57 | + exit_button = tk.Button( |
| 58 | + self, text="Exit", command=self.controller.on_close, |
| 59 | + width=10, height=1, bg="#d9534f", fg="white" |
| 60 | + ) |
| 61 | + exit_button.pack(side="bottom", pady=15) |
0 commit comments