[Update] add Modal Window: When the configuration window is opened, cover the main window with a modal window containing a message.

This commit is contained in:
Sakamoto Shiina
2023-10-02 14:48:42 +09:00
parent 491893acc4
commit 584eb7e33a
7 changed files with 107 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ from customtkinter import CTk, CTkImage
from ._CreateSelectableLanguagesWindow import _CreateSelectableLanguagesWindow
from ._CreateModalWindow import _CreateModalWindow
from ._changeMainWindowWidgetsStatus import _changeMainWindowWidgetsStatus
from ._changeConfigWindowWidgetsStatus import _changeConfigWindowWidgetsStatus
from ._printToTextbox import _printToTextbox
@@ -17,6 +18,8 @@ from utils import callFunctionIfCallable
class VRCT_GUI(CTk):
def __init__(self):
super().__init__()
self.adjusted_event=None
def createGUI(self, settings, view_variable):
self.settings = settings
@@ -41,6 +44,14 @@ class VRCT_GUI(CTk):
view_variable=self._view_variable
)
self.modal_window = _CreateModalWindow(
attach_window=self,
settings=self.settings.modal_window,
view_variable=self._view_variable
)
def startMainLoop(self):
self.mainloop()
@@ -52,9 +63,13 @@ class VRCT_GUI(CTk):
def openConfigWindow(self, e):
callFunctionIfCallable(self._view_variable.CALLBACK_OPEN_CONFIG_WINDOW)
self.adjustToMainWindowGeometry()
self.modal_window.deiconify()
self.bind("<Configure>", self.adjustToMainWindowGeometry)
self.config_window.deiconify()
self.config_window.focus_set()
self.config_window.focus()
self.config_window.grab_set()
def closeConfigWindow(self):
@@ -62,6 +77,9 @@ class VRCT_GUI(CTk):
self.config_window.withdraw()
self.config_window.grab_release()
self.modal_window.withdraw()
self.unbind("<Configure>")
self.adjusted_event=None
@@ -160,4 +178,21 @@ 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 = self.winfo_width()
height_new = self.winfo_height()
self.modal_window.geometry("{}x{}+{}+{}".format(width_new, height_new, x_pos, y_pos))
self.modal_window.lift()
if self.adjusted_event == str(e):
self.after(150, lambda: self.config_window.lift())
elif self.adjusted_event is None:
self.after(150, lambda: self.config_window.lift())
if e is not None:
self.adjusted_event=str(e)
vrct_gui = VRCT_GUI()