Skip to content

Commit edcd978

Browse files
committed
better window centering
1 parent 1536ec0 commit edcd978

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/core/screens/sessions_window.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import tkinter as tk
2-
from core.utils.tk_utils import messagebox
2+
from core.utils.tk_utils import messagebox, center
33
from core.utils.file_utils import get_sessions, get_sessions_directory, get_session_project, get_projects
44
from core.utils.time_utils import format_time
55

@@ -311,7 +311,7 @@ def show_move_session_dialog(self, session_name, current_project, available_proj
311311
dialog.resizable(False, False)
312312

313313
# Center the dialog
314-
dialog.transient(self)
314+
center(dialog)
315315
dialog.grab_set()
316316

317317
# Main frame

src/core/utils/tk_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import os
44
import sys
55

6-
def center(win, offset_x=0, offset_y_percent=0):
6+
def center(win, offset_x=0, offset_y=0):
77
"""
88
Center a Tkinter window on the screen with optional percentage offsets.
99
1010
Args:
1111
win (tk.Tk or tk.Toplevel): The window to center.
1212
offset_x (float): Horizontal offset as a percentage of the screen width.
1313
Positive = move right, negative = move left.
14-
offset_y_percent (float): Vertical offset as a percentage of the screen height.
14+
offset_y (float): Vertical offset as a percentage of the screen height.
1515
Positive = move down, negative = move up.
1616
"""
1717
win.update_idletasks()
@@ -24,7 +24,7 @@ def center(win, offset_x=0, offset_y_percent=0):
2424

2525
# Convert percentage offsets to pixels
2626
offset_x = int(screen_width * (offset_x / 100))
27-
offset_y = int(screen_height * (offset_y_percent / 100))
27+
offset_y = int(screen_height * (offset_y / 100))
2828

2929
# Compute center position
3030
x = int((screen_width / 2) - (width / 2) + offset_x)

0 commit comments

Comments
 (0)