[Update] Config Window: DeepL Auth Key. 認証キー成功時と失敗時に通知として設定画面上に表示。
This commit is contained in:
@@ -5,7 +5,7 @@ from .ui_utils import getLatestWidth, getLatestHeight
|
||||
from utils import isEven
|
||||
|
||||
|
||||
class _CreateErrorWindow(CTkToplevel):
|
||||
class _CreateNotificationWindow(CTkToplevel):
|
||||
def __init__(
|
||||
self,
|
||||
settings,
|
||||
@@ -16,7 +16,8 @@ class _CreateErrorWindow(CTkToplevel):
|
||||
message_ipady,
|
||||
message_font_size,
|
||||
|
||||
message_bg_color,
|
||||
error_message_bg_color,
|
||||
success_message_bg_color,
|
||||
message_text_color,
|
||||
):
|
||||
|
||||
@@ -34,7 +35,8 @@ class _CreateErrorWindow(CTkToplevel):
|
||||
self.message_ipady = message_ipady
|
||||
self.message_font_size = message_font_size
|
||||
|
||||
self.message_bg_color = message_bg_color
|
||||
self.error_message_bg_color = error_message_bg_color
|
||||
self.success_message_bg_color = success_message_bg_color
|
||||
self.message_text_color = message_text_color
|
||||
|
||||
|
||||
@@ -51,20 +53,16 @@ class _CreateErrorWindow(CTkToplevel):
|
||||
self.wm_attributes("-alpha", 0)
|
||||
self.wm_attributes("-toolwindow", True)
|
||||
|
||||
self.configure(fg_color=self.message_bg_color)
|
||||
|
||||
|
||||
|
||||
|
||||
self.grid_rowconfigure(0,weight=1)
|
||||
self.grid_columnconfigure(0,weight=1)
|
||||
|
||||
self.error_message_container = CTkFrame(self, corner_radius=0, fg_color=self.message_bg_color, width=0, height=0)
|
||||
self.error_message_container.grid(row=0, column=0, sticky="nsew")
|
||||
self.notification_message_container = CTkFrame(self, corner_radius=0, width=0, height=0)
|
||||
self.notification_message_container.grid(row=0, column=0, sticky="nsew")
|
||||
|
||||
|
||||
self.error_message_container_label_wrapper = CTkLabel(
|
||||
self.error_message_container,
|
||||
self.notification_message_container_label_wrapper = CTkLabel(
|
||||
self.notification_message_container,
|
||||
# text=message,
|
||||
textvariable=self._view_variable.VAR_ERROR_MESSAGE,
|
||||
height=0,
|
||||
@@ -74,12 +72,19 @@ class _CreateErrorWindow(CTkToplevel):
|
||||
justify="left",
|
||||
text_color=self.message_text_color,
|
||||
)
|
||||
self.error_message_container_label_wrapper.grid(row=0, column=0, padx=self.message_ipadx, pady=self.message_ipady, sticky="nsew")
|
||||
self.notification_message_container_label_wrapper.grid(row=0, column=0, padx=self.message_ipadx, pady=self.message_ipady, sticky="nsew")
|
||||
|
||||
|
||||
|
||||
|
||||
def show(self, target_widget):
|
||||
def show(self, target_widget, message_type):
|
||||
if message_type == "Error":
|
||||
self.notification_message_container.configure(fg_color=self.error_message_bg_color)
|
||||
elif message_type == "Success":
|
||||
self.notification_message_container.configure(fg_color=self.success_message_bg_color)
|
||||
else:
|
||||
raise ValueError("message_type is not selected")
|
||||
|
||||
if self.hide is False:
|
||||
return
|
||||
|
||||
@@ -92,22 +97,23 @@ class _CreateErrorWindow(CTkToplevel):
|
||||
|
||||
self.hide = False
|
||||
|
||||
label_width = getLatestWidth(self.error_message_container_label_wrapper)
|
||||
label_height = getLatestHeight(self.error_message_container_label_wrapper)
|
||||
label_width = getLatestWidth(self.notification_message_container_label_wrapper)
|
||||
label_height = getLatestHeight(self.notification_message_container_label_wrapper)
|
||||
|
||||
# for fixing 1px bug
|
||||
if isEven(label_width) is False:
|
||||
self.error_message_container_label_wrapper.grid(padx=(self.message_ipadx[0], self.message_ipadx[1]-1))
|
||||
self.notification_message_container_label_wrapper.grid(padx=(self.message_ipadx[0], self.message_ipadx[1]-1))
|
||||
else:
|
||||
self.error_message_container_label_wrapper.grid(padx=self.message_ipadx)
|
||||
self.notification_message_container_label_wrapper.grid(padx=self.message_ipadx)
|
||||
|
||||
# for fixing 1px bug
|
||||
if isEven(label_height) is False:
|
||||
self.error_message_container_label_wrapper.grid(pady=(self.message_ipady[0], self.message_ipady[1]-1))
|
||||
self.notification_message_container_label_wrapper.grid(pady=(self.message_ipady[0], self.message_ipady[1]-1))
|
||||
else:
|
||||
self.error_message_container_label_wrapper.grid(pady=self.message_ipady)
|
||||
self.notification_message_container_label_wrapper.grid(pady=self.message_ipady)
|
||||
|
||||
|
||||
# First show animation
|
||||
for i in range(0,101,20):
|
||||
if not self.winfo_exists():
|
||||
break
|
||||
@@ -117,12 +123,14 @@ class _CreateErrorWindow(CTkToplevel):
|
||||
|
||||
sleep(0.1)
|
||||
|
||||
for i in range(0,91,10):
|
||||
if not self.winfo_exists():
|
||||
break
|
||||
self.attributes("-alpha", i/100)
|
||||
self.update()
|
||||
sleep(1/80)
|
||||
# Blink animation
|
||||
if message_type == "Error":
|
||||
for i in range(0,91,10):
|
||||
if not self.winfo_exists():
|
||||
break
|
||||
self.attributes("-alpha", i/100)
|
||||
self.update()
|
||||
sleep(1/80)
|
||||
|
||||
|
||||
def _withdraw(self, e=None):
|
||||
@@ -47,6 +47,7 @@ def createSettingBox_Translation(setting_box_wrapper, config_window, settings, v
|
||||
entry_attr_name="sb__entry_deepl_auth_key",
|
||||
entry_width=settings.uism.RESPONSIVE_UI_SIZE_INT_300,
|
||||
entry_bind__Any_KeyRelease=lambda value: deeplAuthKeyCallback(value),
|
||||
entry_bind__FocusOut=view_variable.CALLBACK_FOCUS_OUT_DEEPL_AUTH_KEY,
|
||||
entry_textvariable=view_variable.VAR_DEEPL_AUTH_KEY,
|
||||
open_authkey_page_command=lambda _e: callFunctionIfCallable(view_variable.CALLBACK_OPEN_WEBPAGE_DEEPL_AUTH_KEY),
|
||||
open_authkey_text_variable=view_variable.VAR_OPEN_DEEPL_WEB_PAGE,
|
||||
|
||||
@@ -294,6 +294,7 @@ def _darkTheme(base_color):
|
||||
# Error Message Window for Config Window
|
||||
# The color code [#bb4448] is a mixture of [#a9555c] and [#cc3333] (for a redder shade).
|
||||
SB__ERROR_MESSAGE_BG_COLOR = "#bb4448",
|
||||
SB__SUCCESS_MESSAGE_BG_COLOR = "#368777",
|
||||
SB__ERROR_MESSAGE_TEXT_COLOR = "#fff",
|
||||
),
|
||||
|
||||
|
||||
@@ -288,6 +288,7 @@ def _lightTheme(base_color):
|
||||
# Error Message Window for Config Window
|
||||
# Check DarkTheme's this part. Based on the color bb4448, used to source, and pick up the number 600 by the generator (https://m2.material.io/design/color/the-color-system.html#tools-for-picking-colors)
|
||||
SB__ERROR_MESSAGE_BG_COLOR = "#cd4c4f",
|
||||
SB__SUCCESS_MESSAGE_BG_COLOR = "#cd4c4f",
|
||||
SB__ERROR_MESSAGE_TEXT_COLOR = "#fff",
|
||||
),
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class UiScalingManager():
|
||||
self.config_window = SimpleNamespace()
|
||||
self.selectable_language_window = SimpleNamespace()
|
||||
self.main_window_cover = SimpleNamespace()
|
||||
self.error_message_window = SimpleNamespace()
|
||||
self.notification_message_window = SimpleNamespace()
|
||||
self.confirmation_modal = SimpleNamespace()
|
||||
self.dropdown_menu_window = SimpleNamespace()
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ from customtkinter import CTk, CTkImage
|
||||
from ._CreateSelectableLanguagesWindow import _CreateSelectableLanguagesWindow
|
||||
|
||||
from ._CreateWindowCover import _CreateWindowCover
|
||||
from ._CreateErrorWindow import _CreateErrorWindow
|
||||
from ._CreateNotificationWindow import _CreateNotificationWindow
|
||||
from ._CreateDropdownMenuWindow import _CreateDropdownMenuWindow
|
||||
from ._changeMainWindowWidgetsStatus import _changeMainWindowWidgetsStatus
|
||||
from ._changeConfigWindowWidgetsStatus import _changeConfigWindowWidgetsStatus
|
||||
@@ -140,8 +140,8 @@ class VRCT_GUI(CTk):
|
||||
view_variable=self._view_variable
|
||||
)
|
||||
|
||||
self.error_message_window = _CreateErrorWindow(
|
||||
settings=self.settings.error_message_window,
|
||||
self.notification_message_window = _CreateNotificationWindow(
|
||||
settings=self.settings.notification_message_window,
|
||||
view_variable=self._view_variable,
|
||||
wrapper_widget=self.config_window.main_bg_container,
|
||||
|
||||
@@ -149,7 +149,8 @@ class VRCT_GUI(CTk):
|
||||
message_ipady=self.settings.config_window.uism.SB__ERROR_MESSAGE_IPADY,
|
||||
message_font_size=self.settings.config_window.uism.SB__ERROR_MESSAGE_FONT_SIZE,
|
||||
|
||||
message_bg_color=self.settings.config_window.ctm.SB__ERROR_MESSAGE_BG_COLOR,
|
||||
error_message_bg_color=self.settings.config_window.ctm.SB__ERROR_MESSAGE_BG_COLOR,
|
||||
success_message_bg_color=self.settings.config_window.ctm.SB__SUCCESS_MESSAGE_BG_COLOR,
|
||||
message_text_color=self.settings.config_window.ctm.SB__ERROR_MESSAGE_TEXT_COLOR,
|
||||
)
|
||||
|
||||
@@ -298,11 +299,14 @@ class VRCT_GUI(CTk):
|
||||
|
||||
|
||||
def _showErrorMessage(self, target_widget):
|
||||
self.error_message_window.show(target_widget=target_widget)
|
||||
self.notification_message_window.show(target_widget=target_widget, message_type="Error")
|
||||
|
||||
def _clearErrorMessage(self):
|
||||
def _showSuccessMessage(self, target_widget):
|
||||
self.notification_message_window.show(target_widget=target_widget, message_type="Success")
|
||||
|
||||
def _clearNotificationMessage(self):
|
||||
try:
|
||||
self.error_message_window._withdraw()
|
||||
self.notification_message_window._withdraw()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user