From aeebb692a11ab3de469fb75f83666c91fa4c521e Mon Sep 17 00:00:00 2001 From: Alessandro <2832077983@qq.com> Date: Sat, 15 Mar 2025 15:41:37 +0800 Subject: [PATCH 1/2] move the page from side to center --- cmdcompass/gui/global_tag.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/cmdcompass/gui/global_tag.py b/cmdcompass/gui/global_tag.py index d084756..dac0305 100644 --- a/cmdcompass/gui/global_tag.py +++ b/cmdcompass/gui/global_tag.py @@ -10,16 +10,21 @@ class GlobalTagWindow(ctk.CTkToplevel): def __init__(self, master, data_manager): super().__init__(master) self.title("Create New Tag") - + screenSize = getScreenSize() tag_window_height = 800 tag_window_width = 270 - x = (screenSize["SCREEN_WIDTH"]*0.01) - y = (screenSize["SCREEN_HEIGHT"]/2) - (tag_window_height/2) + # 计算窗口的中心位置 + x = (screenSize["SCREEN_WIDTH"] / 2) - (tag_window_width / 2) + y = (screenSize["SCREEN_HEIGHT"] / 2) - (tag_window_height / 2) self.geometry('%dx%d+%d+%d' % (tag_window_width, tag_window_height, x, y)) - + + # 确保窗口在主窗口前面显示,并随主窗口位置变化 + self.transient(master) + self.lift() + self.data_manager = data_manager # Main frame to hold everything @@ -137,4 +142,4 @@ def remove_tag(self, tag_uuid): self.data_manager.remove_tag(tag_uuid) self.update_tag_list() # Refresh the tag list except ValueError as e: - CTkMessagebox(title="Error", message=str(e), icon="cancel") + CTkMessagebox(title="Error", message=str(e), icon="cancel") \ No newline at end of file From 8b24385e9b2ab881698ddba3338d914f84a16c1a Mon Sep 17 00:00:00 2001 From: Alessandro <2832077983@qq.com> Date: Sat, 15 Mar 2025 16:06:34 +0800 Subject: [PATCH 2/2] The tag window now can changes with the main window --- cmdcompass/gui/global_tag.py | 11 ++++++----- cmdcompass/gui/main_window.py | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cmdcompass/gui/global_tag.py b/cmdcompass/gui/global_tag.py index dac0305..ad9dd65 100644 --- a/cmdcompass/gui/global_tag.py +++ b/cmdcompass/gui/global_tag.py @@ -7,7 +7,7 @@ class GlobalTagWindow(ctk.CTkToplevel): - def __init__(self, master, data_manager): + def __init__(self, master, data_manager,MainWindow_x,MainWindow_y): super().__init__(master) self.title("Create New Tag") @@ -15,13 +15,14 @@ def __init__(self, master, data_manager): tag_window_height = 800 tag_window_width = 270 - # 计算窗口的中心位置 - x = (screenSize["SCREEN_WIDTH"] / 2) - (tag_window_width / 2) - y = (screenSize["SCREEN_HEIGHT"] / 2) - (tag_window_height / 2) + + + # Calculate the center position of the window + x = (screenSize["SCREEN_WIDTH"] / 3) - (tag_window_width/2) + MainWindow_x + y = (screenSize["SCREEN_HEIGHT"] / 3) - (tag_window_height/2) + MainWindow_y self.geometry('%dx%d+%d+%d' % (tag_window_width, tag_window_height, x, y)) - # 确保窗口在主窗口前面显示,并随主窗口位置变化 self.transient(master) self.lift() diff --git a/cmdcompass/gui/main_window.py b/cmdcompass/gui/main_window.py index 5f5dd07..f708131 100644 --- a/cmdcompass/gui/main_window.py +++ b/cmdcompass/gui/main_window.py @@ -267,7 +267,7 @@ def update_tab_button_states(self): self.comment_tab_button.configure(state="normal", fg_color=DEFAULT_BUTTON_COLOR) def open_tag_creation_window(self): - tag_creation_window = GlobalTagWindow(self, self.data_manager) + tag_creation_window = GlobalTagWindow(self, self.data_manager,self.winfo_x(),self.winfo_y()) tag_creation_window.grab_set() def open_add_tag_window(self, command):