feat: Center main window on screen during initialization
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
This commit is contained in:
23
src/main.py
23
src/main.py
@@ -67,6 +67,29 @@ class MedTrackerApp:
|
|||||||
# Add menu bar
|
# Add menu bar
|
||||||
self._setup_menu()
|
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:
|
def _setup_main_ui(self) -> None:
|
||||||
"""Set up the main UI components."""
|
"""Set up the main UI components."""
|
||||||
import tkinter.ttk as ttk
|
import tkinter.ttk as ttk
|
||||||
|
|||||||
Reference in New Issue
Block a user