[Update/bugfix] Config Window: DeepL Auth Key. DeepLアカウントページを開けるボタンを追加。

メイン画面翻訳エンジン選択のボタンを押した時の処理が2回走っていたのを修正。
This commit is contained in:
Sakamoto Shiina
2024-02-14 23:00:54 +09:00
parent 98c838352b
commit 9e12d43fe0
12 changed files with 147 additions and 12 deletions

View File

@@ -5,7 +5,7 @@ from typing import Union
from customtkinter import CTkFont, CTkFrame, CTkLabel, CTkEntry, CTkSlider, CTkSwitch, CTkCheckBox, CTkProgressBar, CTkImage, CTkRadioButton
from CTkToolTip import *
from vrct_gui.ui_utils import createButtonWithImage, getLatestWidth, createOptionMenuBox, getLatestHeight, bindButtonFunctionAndColor, bindEnterAndLeaveFunction, bindButtonReleaseFunction, bindButtonPressFunction
from vrct_gui.ui_utils import createButtonWithImage, getLatestWidth, createOptionMenuBox, getLatestHeight, bindButtonFunctionAndColor, bindEnterAndLeaveFunction, bindButtonReleaseFunction, bindButtonPressFunction, createLabelButton
from vrct_gui import vrct_gui
from utils import isEven, callFunctionIfCallable
@@ -615,6 +615,75 @@ class _SettingBoxGenerator():
return setting_box_frame
def createSettingBoxEntry_AuthKey(self,
for_var_label_text, for_var_desc_text,
entry_attr_name,
entry_width,
entry_textvariable,
entry_bind__Any_KeyRelease,
entry_bind__FocusOut=None,
open_authkey_page_command=None,
open_authkey_text_variable=None,
image_file=None,
):
(setting_box_frame, setting_box_item_frame) = self._createSettingBoxFrame(entry_attr_name, for_var_label_text, for_var_desc_text)
all_wrapper = CTkFrame(setting_box_item_frame, corner_radius=0, fg_color=self.settings.ctm.SB__BG_COLOR, width=0, height=0)
all_wrapper.grid(row=1, column=0, sticky="ew")
all_wrapper.grid_columnconfigure(0, weight=1)
def adjusted_command__for_entry_bind__Any_KeyRelease(e):
entry_bind__Any_KeyRelease(e.widget.get())
entry_widget = CTkEntry(
all_wrapper,
text_color=self.settings.ctm.SB__ENTRY_TEXT_COLOR,
fg_color=self.settings.ctm.SB__ENTRY_BG_COLOR,
border_color=self.settings.ctm.SB__ENTRY_BORDER_COLOR,
width=entry_width,
height=self.settings.uism.SB__PROGRESSBAR_X_SLIDER__ENTRY_HEIGHT,
textvariable=entry_textvariable,
font=CTkFont(family=self.settings.FONT_FAMILY, size=self.settings.uism.SB__ENTRY_FONT_SIZE, weight="normal"),
)
entry_widget.bind("<Any-KeyRelease>", adjusted_command__for_entry_bind__Any_KeyRelease)
setattr(self.config_window, entry_attr_name, entry_widget)
entry_widget.grid(row=0, column=SETTING_BOX_COLUMN, sticky="e")
if entry_bind__FocusOut is not None:
entry_widget.bind("<FocusOut>", entry_bind__FocusOut, "+")
(open_page_button, label_button_label_widget, label_button_img_widget) = createLabelButton(
parent_widget=all_wrapper,
label_button_bg_color=self.settings.ctm.SB__BUTTON_COLOR,
label_button_hovered_bg_color=self.settings.ctm.SB__BUTTON_HOVERED_COLOR,
label_button_clicked_bg_color=self.settings.ctm.SB__BUTTON_CLICKED_COLOR,
label_button_ipadx=self.settings.uism.SB__AUTHKEY_WEBPAGE_BUTTON_IPADX,
label_button_ipady=self.settings.uism.SB__AUTHKEY_WEBPAGE_BUTTON_IPADY,
variable=open_authkey_text_variable,
font_family=self.settings.FONT_FAMILY,
font_size=self.settings.uism.SB__AUTHKEY_WEBPAGE_BUTTON_LABEL_FONT_SIZE,
text_color=self.settings.ctm.LABELS_TEXT_COLOR,
label_button_clicked_command=open_authkey_page_command,
label_button_position="center",
image_file=image_file,
image_size=self.settings.uism.SB__AUTHKEY_WEBPAGE_BUTTON_IMG_SIZE,
label_button_padx_between_img=self.settings.uism.SB__AUTHKEY_WEBPAGE_PADX_BETWEEN_LABEL_AND_ICON,
)
open_page_button.grid(row=1, column=SETTING_BOX_COLUMN, pady=(self.settings.uism.SB__AUTHKEY_WEBPAGE_BUTTON_TOP_PADY,0))
return setting_box_frame

View File

@@ -6,7 +6,7 @@ def createSettingBox_Translation(setting_box_wrapper, config_window, settings, v
sbg = _SettingBoxGenerator(setting_box_wrapper, config_window, settings, view_variable)
createSettingBoxSwitch = sbg.createSettingBoxSwitch
createSettingBoxDropdownMenu = sbg.createSettingBoxDropdownMenu
createSettingBoxEntry = sbg.createSettingBoxEntry
createSettingBoxEntry_AuthKey = sbg.createSettingBoxEntry_AuthKey
def switchUseTranslationFeatureCallback(switch_widget):
callFunctionIfCallable(view_variable.CALLBACK_SET_USE_TRANSLATION_FEATURE, switch_widget.get())
@@ -41,13 +41,16 @@ def createSettingBox_Translation(setting_box_wrapper, config_window, settings, v
row+=1
config_window.sb__deepl_auth_key = createSettingBoxEntry(
config_window.sb__deepl_auth_key = createSettingBoxEntry_AuthKey(
for_var_label_text=view_variable.VAR_LABEL_DEEPL_AUTH_KEY,
for_var_desc_text=view_variable.VAR_DESC_DEEPL_AUTH_KEY,
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_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,
image_file=settings.image_file.LINK_ICON
)
config_window.sb__deepl_auth_key.grid(row=row, pady=0)
row+=1