From 41d91d9c303acf97bbde0275031e4a8c47502e56 Mon Sep 17 00:00:00 2001 From: William Valentin Date: Fri, 1 Aug 2025 13:05:24 -0700 Subject: [PATCH] feat: Center main window on screen during initialization --- src/main.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main.py b/src/main.py index f6039d6..b0014fe 100644 --- a/src/main.py +++ b/src/main.py @@ -67,6 +67,29 @@ class MedTrackerApp: # Add menu bar self._setup_menu() + # Center the window on screen + self._center_window() + + def _center_window(self) -> None: + """Center the main window on the screen.""" + # Update the window to get accurate dimensions + self.root.update_idletasks() + + # Get window dimensions + window_width = self.root.winfo_reqwidth() + window_height = self.root.winfo_reqheight() + + # Get screen dimensions + screen_width = self.root.winfo_screenwidth() + screen_height = self.root.winfo_screenheight() + + # Calculate position to center the window + x = (screen_width // 2) - (window_width // 2) + y = (screen_height // 2) - (window_height // 2) + + # Set the window geometry + self.root.geometry(f"{window_width}x{window_height}+{x}+{y}") + def _setup_main_ui(self) -> None: """Set up the main UI components.""" import tkinter.ttk as ttk