[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:
@@ -16,6 +16,9 @@ main_window:
|
||||
|
||||
update_available: New version is here!
|
||||
|
||||
modal_message:
|
||||
opened_config_window: The functionality is temporarily disabled until the settings window is closed.
|
||||
|
||||
selectable_language_window:
|
||||
title_your_language: Select Your Language
|
||||
title_target_language: Select Target Language
|
||||
|
||||
@@ -16,6 +16,10 @@ main_window:
|
||||
|
||||
update_available: 新しいバージョンが出ました!
|
||||
|
||||
modal_message:
|
||||
opened_config_window: 設定画面が閉じられるまで、一時的に機能を停止しています。
|
||||
|
||||
|
||||
selectable_language_window:
|
||||
title_your_language: あなたの言語
|
||||
title_target_language: 相手の言語
|
||||
|
||||
9
view.py
9
view.py
@@ -53,6 +53,12 @@ class View():
|
||||
**common_args
|
||||
)
|
||||
|
||||
self.settings.modal_window = SimpleNamespace(
|
||||
ctm=all_ctm.modal_window,
|
||||
uism=all_uism.modal_window,
|
||||
**common_args
|
||||
)
|
||||
|
||||
self.view_variable = SimpleNamespace(
|
||||
# Open Config Window
|
||||
CALLBACK_OPEN_CONFIG_WINDOW=None,
|
||||
@@ -112,6 +118,9 @@ class View():
|
||||
VAR_UPDATE_AVAILABLE=StringVar(value=i18n.t("main_window.update_available")),
|
||||
|
||||
|
||||
# Modal Window For Main Window
|
||||
VAR_LABEL_MODAL_MESSAGE_FOR__MAIN_WINDOW=StringVar(value=i18n.t("main_window.modal_message.opened_config_window")),
|
||||
|
||||
# Selectable Language Window
|
||||
VAR_TITLE_LABEL_SELECTABLE_LANGUAGE=StringVar(value=""),
|
||||
VAR_GO_BACK_LABEL_SELECTABLE_LANGUAGE=StringVar(value=i18n.t("selectable_language_window.go_back_button")),
|
||||
|
||||
49
vrct_gui/_CreateModalWindow.py
Normal file
49
vrct_gui/_CreateModalWindow.py
Normal file
@@ -0,0 +1,49 @@
|
||||
from customtkinter import CTkToplevel, CTkFrame, CTkLabel, CTkFont
|
||||
|
||||
class _CreateModalWindow(CTkToplevel):
|
||||
def __init__(self, attach_window, settings, view_variable):
|
||||
super().__init__()
|
||||
self.withdraw()
|
||||
|
||||
|
||||
self.title("")
|
||||
self.overrideredirect(True)
|
||||
|
||||
self.wm_attributes("-alpha", 0.5)
|
||||
self.wm_attributes("-toolwindow", True)
|
||||
|
||||
self.attach_window = attach_window
|
||||
|
||||
|
||||
self.configure(fg_color="black")
|
||||
self.protocol("WM_DELETE_WINDOW", lambda e: self.withdraw())
|
||||
|
||||
self.settings = settings
|
||||
self._view_variable = view_variable
|
||||
|
||||
|
||||
self.attach_window.update_idletasks()
|
||||
self.x_pos = self.attach_window.winfo_rootx()
|
||||
self.y_pos = self.attach_window.winfo_rooty()
|
||||
self.width_new = self.attach_window.winfo_width()
|
||||
self.height_new = self.attach_window.winfo_height()
|
||||
|
||||
|
||||
self.geometry('{}x{}+{}+{}'.format(self.width_new, self.height_new, self.x_pos, self.y_pos))
|
||||
|
||||
self.rowconfigure(0,weight=1)
|
||||
self.columnconfigure(0,weight=1)
|
||||
self.modal_container = CTkFrame(self, corner_radius=0, fg_color="black", width=0, height=0)
|
||||
self.modal_container.grid(row=0, column=0, sticky="nsew")
|
||||
|
||||
|
||||
self.modal_container_label_wrapper = CTkLabel(
|
||||
self.modal_container,
|
||||
textvariable=self._view_variable.VAR_LABEL_MODAL_MESSAGE_FOR__MAIN_WINDOW,
|
||||
height=0,
|
||||
corner_radius=0,
|
||||
font=CTkFont(family=self.settings.FONT_FAMILY, size=self.settings.uism.TEXT_FONT_SIZE, weight="normal"),
|
||||
anchor="w",
|
||||
text_color=self.settings.ctm.TEXT_COLOR,
|
||||
)
|
||||
self.modal_container_label_wrapper.place(relx=0.5, rely=0.5, anchor="center")
|
||||
@@ -5,6 +5,7 @@ class ColorThemeManager():
|
||||
self.main = SimpleNamespace()
|
||||
self.config_window = SimpleNamespace()
|
||||
self.selectable_language_window = SimpleNamespace()
|
||||
self.modal_window = SimpleNamespace()
|
||||
|
||||
# old one. But leave it here for now.
|
||||
# self.PRIMARY_100_COLOR = "#c4eac1"
|
||||
@@ -207,6 +208,9 @@ class ColorThemeManager():
|
||||
self.selectable_language_window.LANGUAGE_BUTTON_BG_CLICKED_COLOR = self.DARK_888_COLOR
|
||||
|
||||
|
||||
# Modal Window (Main Window)
|
||||
self.modal_window.TEXT_COLOR = self.LIGHT_100_COLOR
|
||||
|
||||
|
||||
# Common
|
||||
self.config_window.BASIC_TEXT_COLOR = self.main.BASIC_TEXT_COLOR
|
||||
|
||||
@@ -6,6 +6,7 @@ class UiScalingManager():
|
||||
self.SCALING_FLOAT = max(scaling_float, 0.4)
|
||||
self.main = SimpleNamespace()
|
||||
self.config_window = SimpleNamespace()
|
||||
self.modal_window = SimpleNamespace()
|
||||
|
||||
self._calculatedUiSizes()
|
||||
|
||||
@@ -96,7 +97,7 @@ class UiScalingManager():
|
||||
self.main.MINIMIZE_SIDEBAR_BUTTON_ICON_SIZE_Y = self._calculateUiSize(26)
|
||||
|
||||
|
||||
|
||||
self.modal_window.TEXT_FONT_SIZE = self._calculateUiSize(20)
|
||||
|
||||
# Top bar common
|
||||
self.config_window.TOP_BAR__HEIGHT = self._calculateUiSize(40)
|
||||
|
||||
@@ -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()
|
||||
Reference in New Issue
Block a user