[bugfix] Main Window, Cover Window: メイン画面に追従しないバグなど修正。追従する関数やイベント登録もcover windowクラス内に押し込み。
This commit is contained in:
4
view.py
4
view.py
@@ -627,14 +627,14 @@ class View():
|
||||
self.view_variable.VAR_LABEL_MAIN_WINDOW_COVER_MESSAGE.set("")
|
||||
vrct_gui.main_window_cover.show()
|
||||
|
||||
# self.view_variable.CALLBACK_HIDE_CONFIRMATION_MODAL=self._hideConfirmationModal
|
||||
self.view_variable.CALLBACK_HIDE_CONFIRMATION_MODAL=self._hideInformationModal
|
||||
self.view_variable.CALLBACK_ACCEPTED_CONFIRMATION_MODAL=self._hideInformationModal
|
||||
# self.view_variable.CALLBACK_DENIED_CONFIRMATION_MODAL=self._hideConfirmationModal
|
||||
|
||||
self.view_variable.VAR_MESSAGE_CONFIRMATION_MODAL.set(i18n.t("main_window.confirmation_message.translation_engine_limit_error"))
|
||||
# self.view_variable.VAR_LABEL_CONFIRMATION_MODAL_DENY_BUTTON.set(i18n.t("main_window.confirmation_message.deny_update_software"))
|
||||
self.view_variable.VAR_LABEL_CONFIRMATION_MODAL_ACCEPT_BUTTON.set(i18n.t("main_window.confirmation_message.accept_translation_engine_limit_error"))
|
||||
vrct_gui.information_modal.show(close_when_focusout=False)
|
||||
vrct_gui.information_modal.show(hide_title_bar=False, close_when_focusout=False)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
from customtkinter import CTkToplevel, CTkFrame, CTkLabel, CTkFont
|
||||
|
||||
from .ui_utils import fadeInAnimation
|
||||
from utils import makeEven
|
||||
|
||||
class _CreateWindowCover(CTkToplevel):
|
||||
def __init__(self, attach_window, settings, view_variable):
|
||||
super().__init__()
|
||||
self.withdraw()
|
||||
|
||||
self.BIND_CONFIGURE_ADJUSTED_GEOMETRY_FUNC_ID=None
|
||||
self.BIND_FOCUS_IN_FUNC_ID=None
|
||||
|
||||
self.title("")
|
||||
self.overrideredirect(True)
|
||||
@@ -40,7 +43,14 @@ class _CreateWindowCover(CTkToplevel):
|
||||
self.cover_container_label_wrapper.place(relx=0.5, rely=0.5, anchor="center")
|
||||
|
||||
|
||||
def show(self):
|
||||
def show(self, bind_focusin=None):
|
||||
self.BIND_CONFIGURE_ADJUSTED_GEOMETRY_FUNC_ID = self.attach_window.bind("<Configure>", self._adjustToMainWindowGeometry, "+")
|
||||
if bind_focusin is not None:
|
||||
self.BIND_FOCUS_IN_FUNC_ID = self.bind("<FocusIn>", lambda _e: bind_focusin(), "+")
|
||||
else:
|
||||
self.BIND_FOCUS_IN_FUNC_ID = None
|
||||
|
||||
|
||||
self.attributes("-alpha", 0)
|
||||
self.deiconify()
|
||||
self.attach_window.update_idletasks()
|
||||
@@ -52,5 +62,22 @@ class _CreateWindowCover(CTkToplevel):
|
||||
fadeInAnimation(self, steps=5, interval=0.005, max_alpha=0.5)
|
||||
|
||||
|
||||
|
||||
def hide(self):
|
||||
self.attach_window.unbind("<Configure>", self.BIND_CONFIGURE_ADJUSTED_GEOMETRY_FUNC_ID)
|
||||
if self.BIND_FOCUS_IN_FUNC_ID is not None:
|
||||
self.unbind("<FocusIn>", self.BIND_FOCUS_IN_FUNC_ID)
|
||||
|
||||
self.withdraw()
|
||||
|
||||
|
||||
|
||||
def _adjustToMainWindowGeometry(self, e=None):
|
||||
self.attach_window.update_idletasks()
|
||||
x_pos = self.attach_window.winfo_rootx()
|
||||
y_pos = self.attach_window.winfo_rooty()
|
||||
width_new = makeEven(self.attach_window.winfo_width())
|
||||
height_new = makeEven(self.attach_window.winfo_height())
|
||||
self.geometry("{}x{}+{}+{}".format(width_new, height_new, x_pos, y_pos))
|
||||
|
||||
self.lift()
|
||||
@@ -14,15 +14,13 @@ from .main_window import createMainWindowWidgets
|
||||
from .config_window import ConfigWindow
|
||||
from .ui_utils import setDefaultActiveTab, setGeometryToCenterOfScreen, fadeInAnimation
|
||||
|
||||
from utils import callFunctionIfCallable, makeEven
|
||||
from utils import callFunctionIfCallable
|
||||
|
||||
class VRCT_GUI(CTk):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.withdraw()
|
||||
self.is_config_window_already_opened_once=False
|
||||
self.BIND_CONFIGURE_ADJUSTED_GEOMETRY_FUNC_ID=None
|
||||
self.BIND_FOCUS_IN_MODAL_WINDOW_LIFT_CONFIG_WINDOW_FUNC_ID=None
|
||||
self.BIND_UNMAP_DETECT_MAIN_WINDOW_STATE_FUNC_ID = None
|
||||
self.BIND_MAP_DETECT_MAIN_WINDOW_STATE_FUNC_ID = None
|
||||
|
||||
@@ -104,7 +102,7 @@ class VRCT_GUI(CTk):
|
||||
)
|
||||
|
||||
self.main_window_cover = _CreateWindowCover(
|
||||
attach_window=self.toplevel_wrapper,
|
||||
attach_window=self,
|
||||
settings=self.settings.main_window_cover,
|
||||
view_variable=self._view_variable
|
||||
)
|
||||
@@ -150,14 +148,11 @@ class VRCT_GUI(CTk):
|
||||
|
||||
|
||||
def _openConfigWindow(self):
|
||||
self.main_window_cover.show()
|
||||
|
||||
self.BIND_CONFIGURE_ADJUSTED_GEOMETRY_FUNC_ID = self.bind("<Configure>", self._adjustToMainWindowGeometry, "+")
|
||||
self.main_window_cover.show(bind_focusin=self.config_window.lift)
|
||||
|
||||
self.BIND_UNMAP_DETECT_MAIN_WINDOW_STATE_FUNC_ID = self.bind("<Unmap>", self.detectMainWindowState, "+")
|
||||
self.BIND_MAP_DETECT_MAIN_WINDOW_STATE_FUNC_ID = self.bind("<Map>", self.detectMainWindowState, "+")
|
||||
|
||||
self.BIND_FOCUS_IN_MODAL_WINDOW_LIFT_CONFIG_WINDOW_FUNC_ID = self.main_window_cover.bind("<FocusIn>", lambda _e: self.config_window.lift(), "+")
|
||||
|
||||
self.config_window.attributes("-alpha", 0)
|
||||
self.config_window.deiconify()
|
||||
@@ -172,10 +167,8 @@ class VRCT_GUI(CTk):
|
||||
self.config_window.withdraw()
|
||||
|
||||
self.main_window_cover.hide()
|
||||
self.unbind("<Configure>", self.BIND_CONFIGURE_ADJUSTED_GEOMETRY_FUNC_ID)
|
||||
self.unbind("<Unmap>", self.BIND_UNMAP_DETECT_MAIN_WINDOW_STATE_FUNC_ID)
|
||||
self.unbind("<Map>", self.BIND_MAP_DETECT_MAIN_WINDOW_STATE_FUNC_ID)
|
||||
self.main_window_cover.unbind("<FocusIn>", self.BIND_FOCUS_IN_MODAL_WINDOW_LIFT_CONFIG_WINDOW_FUNC_ID)
|
||||
self.adjusted_event=None
|
||||
|
||||
|
||||
@@ -276,16 +269,6 @@ class VRCT_GUI(CTk):
|
||||
self.minimize_sidebar_button_container__for_closing.grid()
|
||||
|
||||
|
||||
def _adjustToMainWindowGeometry(self, e=None):
|
||||
self.update_idletasks()
|
||||
x_pos = self.winfo_rootx()
|
||||
y_pos = self.winfo_rooty()
|
||||
width_new = makeEven(self.winfo_width())
|
||||
height_new = makeEven(self.winfo_height())
|
||||
self.main_window_cover.geometry("{}x{}+{}+{}".format(width_new, height_new, x_pos, y_pos))
|
||||
|
||||
self.main_window_cover.lift()
|
||||
|
||||
def _showErrorMessage(self, target_widget):
|
||||
self.error_message_window.show(target_widget=target_widget)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user