From 2ee8eca63bf0a3b3d2369070d2595b675192467b Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Sat, 2 Sep 2023 02:19:23 +0900 Subject: [PATCH] =?UTF-8?q?Config=20Window=20=E5=90=84=E8=A8=AD=E5=AE=9A?= =?UTF-8?q?=E9=A0=85=E7=9B=AE=E3=82=92=E5=A4=89=E6=95=B0=E5=8C=96=E3=81=97?= =?UTF-8?q?=E3=80=81ctk=20variable=E3=81=AA=E3=81=A9=E5=85=A8=E3=81=A6view?= =?UTF-8?q?.py=E3=81=AB=E7=A7=BB=E5=8B=95=E3=80=82=20vrct=5Fgui=E4=BB=A5?= =?UTF-8?q?=E4=B8=8B=E3=81=A7=E3=81=AFconfig.py=E3=82=92=E4=BD=BF=E3=82=8F?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=E5=88=87=E3=82=8A?= =?UTF-8?q?=E9=9B=A2=E3=81=97=E3=81=9F=E3=80=82=20CTkScrollableDropdown?= =?UTF-8?q?=E3=82=92=E4=BD=BF=E3=81=86=E3=81=93=E3=81=A8=E3=82=92=E3=82=84?= =?UTF-8?q?=E3=82=81=E3=81=9F=E3=80=82(grab=5Fset=E3=81=A8=E5=B9=B2?= =?UTF-8?q?=E6=B8=89=E3=81=99=E3=82=8B=E3=81=9F=E3=82=81)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 4 + view.py | 186 +++++++++++++++++- vrct_gui/config_window/ConfigWindow.py | 44 +---- .../_SettingBoxGenerator.py | 96 ++++----- .../createSettingBox_AdvancedSettings.py | 14 +- .../createSettingBox_Appearance.py | 53 +++-- .../createSettingBox_Others.py | 18 +- .../createSettingBox_Mic.py | 68 +++---- .../createSettingBox_Speaker.py | 42 ++-- .../createSettingBox_Translation.py | 6 +- .../main_window/createMainWindowWidgets.py | 2 +- vrct_gui/vrct_gui.py | 9 +- 12 files changed, 337 insertions(+), 205 deletions(-) diff --git a/main.py b/main.py index c939d26b..03774d60 100644 --- a/main.py +++ b/main.py @@ -2,6 +2,8 @@ from threading import Thread from config import config from model import model from view import view +from utils import get_key_by_value +from languages import selectable_languages # func transcription send message def sendMicMessage(message): @@ -244,6 +246,8 @@ def callbackSetFontFamily(value): def callbackSetUiLanguage(value): print("callbackSetUiLanguage", value) + value = get_key_by_value(selectable_languages, value) + print("callbackSetUiLanguage__after_get_key_by_value", value) config.UI_LANGUAGE = value # Translation Tab diff --git a/view.py b/view.py index 975921f8..5f37da6a 100644 --- a/view.py +++ b/view.py @@ -1,6 +1,8 @@ from types import SimpleNamespace +from tkinter import font as tk_font +from languages import selectable_languages -from customtkinter import StringVar, END as CTK_END, get_appearance_mode +from customtkinter import StringVar, IntVar, BooleanVar, END as CTK_END, get_appearance_mode from vrct_gui.ui_managers import ColorThemeManager, ImageFilenameManager, UiScalingManager from vrct_gui import vrct_gui @@ -34,6 +36,170 @@ class View(): **common_args ) + self.view_variable = SimpleNamespace( + VAR_LABEL_TRANSPARENCY=StringVar(value="Transparency"), + VAR_DESC_TRANSPARENCY=StringVar(value="Change the window's transparency. 50% to 100%. (Default: 100%)"), + SLIDER_RANGE_TRANSPARENCY=(50, 100), + CALLBACK_SET_TRANSPARENCY=None, + VAR_TRANSPARENCY=IntVar(value=config.TRANSPARENCY), + + VAR_LABEL_APPEARANCE_THEME=StringVar(value="Theme"), + VAR_DESC_APPEARANCE_THEME=StringVar(value="Change the color theme from \"Light\" and \"Dark\". If you select \"System\", It will adjust based on your Windows theme. (Default: System)"), + LIST_APPEARANCE_THEME=["Light", "Dark", "System"], + CALLBACK_SET_APPEARANCE_THEME=None, + VAR_APPEARANCE_THEME=StringVar(value=config.APPEARANCE_THEME), + + VAR_LABEL_UI_SCALING=StringVar(value="UI Size"), + VAR_DESC_UI_SCALING=StringVar(value="(Default: 100%)"), + LIST_UI_SCALING=["80%", "90%", "100%", "110%", "120%"], + CALLBACK_SET_UI_SCALING=None, + VAR_UI_SCALING=StringVar(value=config.UI_SCALING), + + VAR_LABEL_FONT_FAMILY=StringVar(value="Font Family"), + VAR_DESC_FONT_FAMILY=StringVar(value="(Default: Yu Gothic UI)"), + LIST_FONT_FAMILY=list(tk_font.families()), + CALLBACK_SET_FONT_FAMILY=None, + VAR_FONT_FAMILY=StringVar(value=config.FONT_FAMILY), + + VAR_LABEL_UI_LANGUAGE=StringVar(value="UI Language"), + VAR_DESC_UI_LANGUAGE=StringVar(value="(Default: English)"), + LIST_UI_LANGUAGE=list(selectable_languages.values()), + CALLBACK_SET_UI_LANGUAGE=None, + VAR_UI_LANGUAGE=StringVar(value=selectable_languages[config.UI_LANGUAGE]), + + + + VAR_LABEL_DEEPL_AUTH_KEY=StringVar(value="DeepL Auth Key"), + VAR_DESC_DEEPL_AUTH_KEY=None, + # VAR_DESC_DEEPL_AUTH_KEY=StringVar(value=""), + CALLBACK_SET_DEEPL_AUTH_KEY=None, + VAR_DEEPL_AUTH_KEY=StringVar(value=config.AUTH_KEYS["DeepL(auth)"]), + + + + VAR_LABEL_MIC_HOST=StringVar(value="Mic Host"), + VAR_DESC_MIC_HOST=StringVar(value="Select the mic host. (Default: ?)"), + LIST_MIC_HOST=[], # model.getListInputHost(), + CALLBACK_SET_MIC_HOST=None, + VAR_MIC_HOST=StringVar(value=config.CHOICE_MIC_HOST), + + VAR_LABEL_MIC_DEVICE=StringVar(value="Mic Device"), + VAR_DESC_MIC_DEVICE=StringVar(value="Select the mic devise. (Default: ?)"), + LIST_MIC_DEVICE=[], # model.getListInputDevice(), + CALLBACK_SET_MIC_DEVICE=None, + VAR_MIC_DEVICE=StringVar(value=config.CHOICE_MIC_DEVICE), + + VAR_LABEL_MIC_ENERGY_THRESHOLD=StringVar(value="Mic Energy Threshold"), + VAR_DESC_MIC_ENERGY_THRESHOLD=StringVar(value="Slider to modify the threshold for activating voice input.\nPress the microphone button to start input and speak something, so you can adjust it while monitoring the actual volume. 0 to 2000 (Default: 300)"), + SLIDER_RANGE_MIC_ENERGY_THRESHOLD=(0, config.MAX_MIC_ENERGY_THRESHOLD), + CALLBACK_CHECK_MIC_THRESHOLD=None, + VAR_MIC_ENERGY_THRESHOLD=IntVar(value=config.INPUT_MIC_ENERGY_THRESHOLD), + + VAR_LABEL_MIC_DYNAMIC_ENERGY_THRESHOLD=StringVar(value="Mic Dynamic Energy Threshold"), + VAR_DESC_MIC_DYNAMIC_ENERGY_THRESHOLD=StringVar(value="When this feature is selected, it will automatically adjust in a way that works well, based on the set Mic Energy Threshold."), + CALLBACK_SET_MIC_DYNAMIC_ENERGY_THRESHOLD=None, + VAR_MIC_DYNAMIC_ENERGY_THRESHOLD=BooleanVar(value=config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD), + + VAR_LABEL_MIC_RECORD_TIMEOUT=StringVar(value="Mic Record Timeout"), + VAR_DESC_MIC_RECORD_TIMEOUT=StringVar(value="(Default: 3)"), + CALLBACK_SET_MIC_RECORD_TIMEOUT=None, + VAR_MIC_RECORD_TIMEOUT=IntVar(value=config.INPUT_MIC_RECORD_TIMEOUT), + + VAR_LABEL_MIC_PHRASE_TIMEOUT=StringVar(value="Mic Phrase Timeout"), + VAR_DESC_MIC_PHRASE_TIMEOUT=StringVar(value="(Default: 3)"), + CALLBACK_SET_MIC_PHRASE_TIMEOUT=None, + VAR_MIC_PHRASE_TIMEOUT=IntVar(value=config.INPUT_MIC_PHRASE_TIMEOUT), + + VAR_LABEL_MIC_MAX_PHRASES=StringVar(value="Mic Max Phrases"), + VAR_DESC_MIC_MAX_PHRASES=StringVar(value="It will stop recording and send the recordings when the set count of phrase(s) is reached. (Default: 10)"), + CALLBACK_SET_MIC_MAX_PHRASES=None, + VAR_MIC_MAX_PHRASES=IntVar(value=config.INPUT_MIC_MAX_PHRASES), + + + VAR_LABEL_MIC_WORD_FILTER=StringVar(value="Mic Word Filter"), + VAR_DESC_MIC_WORD_FILTER=StringVar(value="It will not send the sentence if the word(s) included in the set list of words.\nHow to set: e.g. AAA,BBB,CCC"), + CALLBACK_SET_MIC_WORD_FILTER=None, + VAR_MIC_WORD_FILTER=StringVar(value=",".join(config.INPUT_MIC_WORD_FILTER) if len(config.INPUT_MIC_WORD_FILTER) > 0 else ""), + + + + + + + + + + + + VAR_LABEL_SPEAKER_DEVICE=StringVar(value="Speaker Device"), + VAR_DESC_SPEAKER_DEVICE=StringVar(value="Select the speaker devise. (Default: ?)"), + LIST_SPEAKER_DEVICE=[], # model.getListOutputDevice(), + CALLBACK_SET_SPEAKER_DEVICE=None, + VAR_SPEAKER_DEVICE=StringVar(value=config.CHOICE_SPEAKER_DEVICE), + + VAR_LABEL_SPEAKER_ENERGY_THRESHOLD=StringVar(value="Mic Energy Threshold"), + VAR_DESC_SPEAKER_ENERGY_THRESHOLD=StringVar(value="Slider to modify the threshold for activating voice input.\nPress the headphones mark button to start input and speak something, so you can adjust it while monitoring the actual volume. 0 to 4000 (Default: 300)"), + SLIDER_RANGE_SPEAKER_ENERGY_THRESHOLD=(0, config.MAX_SPEAKER_ENERGY_THRESHOLD), + CALLBACK_CHECK_SPEAKER_THRESHOLD=None, + VAR_SPEAKER_ENERGY_THRESHOLD=IntVar(value=config.INPUT_SPEAKER_ENERGY_THRESHOLD), + + VAR_LABEL_SPEAKER_DYNAMIC_ENERGY_THRESHOLD=StringVar(value="Speaker Dynamic Energy Threshold"), + VAR_DESC_SPEAKER_DYNAMIC_ENERGY_THRESHOLD=StringVar(value="When this feature is selected, it will automatically adjust in a way that works well, based on the set Speaker Energy Threshold."), + CALLBACK_SET_SPEAKER_DYNAMIC_ENERGY_THRESHOLD=None, + VAR_SPEAKER_DYNAMIC_ENERGY_THRESHOLD=BooleanVar(value=config.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD), + + VAR_LABEL_SPEAKER_RECORD_TIMEOUT=StringVar(value="Speaker Record Timeout"), + VAR_DESC_SPEAKER_RECORD_TIMEOUT=StringVar(value="(Default: 3)"), + CALLBACK_SET_SPEAKER_RECORD_TIMEOUT=None, + VAR_SPEAKER_RECORD_TIMEOUT=IntVar(value=config.INPUT_SPEAKER_RECORD_TIMEOUT), + + VAR_LABEL_SPEAKER_PHRASE_TIMEOUT=StringVar(value="Speaker Phrase Timeout"), + VAR_DESC_SPEAKER_PHRASE_TIMEOUT=StringVar(value="It will stop recording and receive the recordings when the set second(s) is reached. (Default: 3)"), + CALLBACK_SET_SPEAKER_PHRASE_TIMEOUT=None, + VAR_SPEAKER_PHRASE_TIMEOUT=IntVar(value=config.INPUT_SPEAKER_PHRASE_TIMEOUT), + + VAR_LABEL_SPEAKER_MAX_PHRASES=StringVar(value="Speaker Max Phrases"), + VAR_DESC_SPEAKER_MAX_PHRASES=StringVar(value="It will stop recording and receive the recordings when the set count of phrase(s) is reached. (Default: 10)"), + CALLBACK_SET_SPEAKER_MAX_PHRASES=None, + VAR_SPEAKER_MAX_PHRASES=IntVar(value=config.INPUT_SPEAKER_MAX_PHRASES), + + + + + + + VAR_LABEL_ENABLE_AUTO_CLEAR_MESSAGE_BOX=StringVar(value="Auto Clear The Message Box"), + VAR_DESC_ENABLE_AUTO_CLEAR_MESSAGE_BOX=StringVar(value="Clear the message box after sending your message."), + CALLBACK_SET_ENABLE_AUTO_CLEAR_MESSAGE_BOX=None, + VAR_ENABLE_AUTO_CLEAR_MESSAGE_BOX=BooleanVar(value=config.ENABLE_AUTO_CLEAR_MESSAGE_BOX), + + VAR_LABEL_ENABLE_NOTICE_XSOVERLAY=StringVar(value="Notification XSOverlay (VR Only)"), + VAR_DESC_ENABLE_NOTICE_XSOVERLAY=StringVar(value="Notify received messages by using XSOverlay's notification feature."), + CALLBACK_SET_ENABLE_NOTICE_XSOVERLAY=None, + VAR_ENABLE_NOTICE_XSOVERLAY=BooleanVar(value=config.ENABLE_NOTICE_XSOVERLAY), + + VAR_LABEL_MESSAGE_FORMAT=StringVar(value="Message Format"), + VAR_DESC_MESSAGE_FORMAT=StringVar(value="You can change the decoration of the message you want to send. (Default: \"[message]([translation])\" )"), + CALLBACK_SET_MESSAGE_FORMAT=None, + VAR_MESSAGE_FORMAT=StringVar(value=config.MESSAGE_FORMAT), + + + + + + VAR_LABEL_OSC_IP_ADDRESS=StringVar(value="OSC IP Address"), + VAR_DESC_OSC_IP_ADDRESS=StringVar(value="(Default: 127.0.0.1)"), + CALLBACK_SET_OSC_IP_ADDRESS=None, + VAR_OSC_IP_ADDRESS=IntVar(value=config.OSC_IP_ADDRESS), + + VAR_LABEL_OSC_PORT=StringVar(value="OSC Port"), + VAR_DESC_OSC_PORT=StringVar(value="(Default: 9000)"), + CALLBACK_SET_OSC_PORT=None, + VAR_OSC_PORT=IntVar(value=config.OSC_PORT), + + ) + + def register(self, sidebar_features, language_presets, entry_message_box_commands, config_window): @@ -72,9 +238,23 @@ class View(): # Appearance Tab vrct_gui.config_window.CALLBACK_SET_TRANSPARENCY = config_window["callback_set_transparency"] + # vrct_gui.config_window.sb__transparency_slider.configure(variable=IntVar(value=config.TRANSPARENCY)) + vrct_gui.config_window.CALLBACK_SET_APPEARANCE = config_window["callback_set_appearance"] vrct_gui.config_window.CALLBACK_SET_UI_SCALING = config_window["callback_set_ui_scaling"] - vrct_gui.config_window.CALLBACK_SET_FONT_FAMILY = config_window["callback_set_font_family"] + + self.view_variable.CALLBACK_SET_FONT_FAMILY = config_window["callback_set_font_family"] + + # vrct_gui.config_window.sb__optionmenu_font_family.configure(values=self.view_variable.LIST_FONT_FAMILY) + + # self.view_variable.VAR_FONT_FAMILY = StringVar(value=config.FONT_FAMILY) + # vrct_gui.config_window.sb__optionmenu_font_family.configure(variable=self.view_variable.VAR_FONT_FAMILY) + + + + # vrct_gui.config_window.sb__optionmenu_font_family.configure(variable=StringVar(value=config.FONT_FAMILY)) + # vrct_gui.config_window.sb__optionmenu_font_family.configure(values=["test", "from", "view.py"]) + vrct_gui.config_window.CALLBACK_SET_UI_LANGUAGE = config_window["callback_set_ui_language"] @@ -216,7 +396,7 @@ class View(): def createGUI(self): - vrct_gui.createGUI(settings=self.settings) + vrct_gui.createGUI(settings=self.settings, view_variable=self.view_variable) def startMainLoop(self): vrct_gui.startMainLoop() diff --git a/vrct_gui/config_window/ConfigWindow.py b/vrct_gui/config_window/ConfigWindow.py index 25e03688..c2c87c1c 100644 --- a/vrct_gui/config_window/ConfigWindow.py +++ b/vrct_gui/config_window/ConfigWindow.py @@ -4,7 +4,7 @@ from .widgets import createConfigWindowTitle, createSideMenuAndSettingsBoxContai from customtkinter import CTkToplevel class ConfigWindow(CTkToplevel): - def __init__(self, vrct_gui, settings): + def __init__(self, vrct_gui, settings, view_variable): super().__init__() self.withdraw() @@ -18,47 +18,7 @@ class ConfigWindow(CTkToplevel): self.protocol("WM_DELETE_WINDOW", vrct_gui.closeConfigWindow) self.settings = settings - - - # Appearance Tab - self.CALLBACK_SET_TRANSPARENCY = None - self.CALLBACK_SET_APPEARANCE = None - self.CALLBACK_SET_UI_SCALING = None - self.CALLBACK_SET_FONT_FAMILY = None - self.CALLBACK_SET_UI_LANGUAGE = None - - # Translation Tab - self.CALLBACK_SET_DEEPL_AUTHKEY = None - - # Transcription Tab (Mic) - self.CALLBACK_SET_MIC_HOST = None - self.CALLBACK_SET_MIC_DEVICE = None - self.CALLBACK_SET_MIC_ENERGY_THRESHOLD = None - self.CALLBACK_SET_MIC_DYNAMIC_ENERGY_THRESHOLD = None - self.CALLBACK_CHECK_MIC_THRESHOLD = None - self.CALLBACK_SET_MIC_RECORD_TIMEOUT = None - self.CALLBACK_SET_MIC_PHRASE_TIMEOUT = None - self.CALLBACK_SET_MIC_MAX_PHRASES = None - self.CALLBACK_SET_MIC_WORD_FILTER = None - - # Transcription Tab (Speaker) - self.CALLBACK_SET_SPEAKER_DEVICE = None - self.CALLBACK_SET_SPEAKER_ENERGY_THRESHOLD = None - self.CALLBACK_SET_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = None - self.CALLBACK_CHECK_SPEAKER_THRESHOLD = None - self.CALLBACK_SET_SPEAKER_RECORD_TIMEOUT = None - self.CALLBACK_SET_SPEAKER_PHRASE_TIMEOUT = None - self.CALLBACK_SET_SPEAKER_MAX_PHRASES = None - - # Others Tab - self.CALLBACK_SET_ENABLE_AUTO_CLEAR_MESSAGE_BOX = None - self.CALLBACK_SET_ENABLE_NOTICE_XSOVERLAY = None - self.CALLBACK_SET_MESSAGE_FORMAT = None - - # Advanced Settings Tab - self.CALLBACK_SET_OSC_IP_ADDRESS = None - self.CALLBACK_SET_OSC_PORT = None - + self.view_variable = view_variable createConfigWindowTitle(config_window=self, settings=settings) diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py index ebeca5ac..d6044900 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py @@ -1,4 +1,4 @@ -from customtkinter import CTkOptionMenu, CTkFont, CTkFrame, CTkLabel, CTkRadioButton, CTkEntry, CTkSlider, CTkSwitch, CTkCheckBox, CTkProgressBar, END as CTK_END +from customtkinter import CTkOptionMenu, CTkFont, CTkFrame, CTkLabel, CTkRadioButton, CTkEntry, CTkSlider, CTkSwitch, CTkCheckBox, CTkProgressBar, END as CTK_END, StringVar, IntVar from ctk_scrollable_dropdown import CTkScrollableDropdown from vrct_gui.ui_utils import createButtonWithImage @@ -23,22 +23,22 @@ class _SettingBoxGenerator(): setting_box_frame_wrapper.grid_columnconfigure((0,1), weight=1, minsize=int(self.uism.SB__MAIN_WIDTH / 2)) return setting_box_frame_wrapper - def _createSettingBoxFrame(self, parent_widget, label_text, desc_text): + def _createSettingBoxFrame(self, parent_widget, for_var_label_text, for_var_desc_text): setting_box_frame = CTkFrame(parent_widget, corner_radius=0, fg_color=self.ctm.SB__BG_COLOR, width=0, height=0) setting_box_frame_wrapper = self._createSettingBoxFrameWrapper(setting_box_frame) - self._setSettingBoxLabels(setting_box_frame_wrapper, label_text, desc_text) + self._setSettingBoxLabels(setting_box_frame_wrapper, for_var_label_text, for_var_desc_text) # "pady=(0,1)" is for bottom padding. It can be removed(override) when you do like "self.attr_name.grid(row=row, pady=0)" setting_box_frame.grid(column=0, padx=0, pady=(0,1), sticky="ew") return (setting_box_frame, setting_box_frame_wrapper) - def _setSettingBoxLabels(self, setting_box_frame, label_text, desc_text=False): + def _setSettingBoxLabels(self, setting_box_frame, for_var_label_text, for_var_desc_text=None): setting_box_labels_frame = CTkFrame(setting_box_frame, corner_radius=0, fg_color=self.ctm.SB__BG_COLOR, width=0, height=0) setting_box_label = CTkLabel( setting_box_labels_frame, - text=label_text, + textvariable=for_var_label_text, anchor="w", # height=0, font=CTkFont(family=self.FONT_FAMILY, size=self.uism.SB__LABEL_FONT_SIZE, weight="normal"), @@ -46,12 +46,12 @@ class _SettingBoxGenerator(): ) setting_box_label.grid(row=0, column=0, padx=0, pady=0, sticky="ew") - if desc_text == False or self.IS_CONFIG_WINDOW_COMPACT_MODE is True: + if for_var_desc_text == None or self.IS_CONFIG_WINDOW_COMPACT_MODE is True: pass else: self.setting_box_desc = CTkLabel( setting_box_labels_frame, - text=desc_text, + textvariable=for_var_desc_text, anchor="w", justify="left", # height=0, @@ -65,8 +65,8 @@ class _SettingBoxGenerator(): - def createSettingBoxDropdownMenu(self, parent_widget, label_text, desc_text, optionmenu_attr_name, dropdown_menu_attr_name, dropdown_menu_values, command, variable): - (setting_box_frame, setting_box_frame_wrapper) = self._createSettingBoxFrame(parent_widget, label_text, desc_text) + def createSettingBoxDropdownMenu(self, parent_widget, for_var_label_text, for_var_desc_text, optionmenu_attr_name, command, variable=None, dropdown_menu_attr_name=None, dropdown_menu_values=None): + (setting_box_frame, setting_box_frame_wrapper) = self._createSettingBoxFrame(parent_widget, for_var_label_text, for_var_desc_text) setting_box_dropdown_menu_frame = CTkFrame(setting_box_frame_wrapper, corner_radius=0, width=0, height=0, fg_color=self.ctm.SB__BG_COLOR) setting_box_dropdown_menu_frame.grid(row=0, column=1, padx=0, sticky="e") @@ -74,7 +74,6 @@ class _SettingBoxGenerator(): self.createOption_DropdownMenu( setting_box_dropdown_menu_frame=setting_box_dropdown_menu_frame, optionmenu_attr_name=optionmenu_attr_name, - dropdown_menu_attr_name=dropdown_menu_attr_name, dropdown_menu_values=dropdown_menu_values, command=command, variable=variable, @@ -85,8 +84,8 @@ class _SettingBoxGenerator(): - def createSettingBoxSwitch(self, parent_widget, label_text, desc_text, switch_attr_name, is_checked, command): - (setting_box_frame, setting_box_frame_wrapper) = self._createSettingBoxFrame(parent_widget, label_text, desc_text) + def createSettingBoxSwitch(self, parent_widget, for_var_label_text, for_var_desc_text, switch_attr_name, is_checked, command): + (setting_box_frame, setting_box_frame_wrapper) = self._createSettingBoxFrame(parent_widget, for_var_label_text, for_var_desc_text) setting_box_switch_frame = CTkFrame(setting_box_frame_wrapper, corner_radius=0, width=0, height=0, fg_color=self.ctm.SB__BG_COLOR) setting_box_switch_frame.grid(row=0, column=1, padx=0, sticky="e") @@ -117,8 +116,8 @@ class _SettingBoxGenerator(): - def createSettingBoxCheckbox(self, parent_widget, label_text, desc_text, checkbox_attr_name, is_checked, command): - (setting_box_frame, setting_box_frame_wrapper) = self._createSettingBoxFrame(parent_widget, label_text, desc_text) + def createSettingBoxCheckbox(self, parent_widget, for_var_label_text, for_var_desc_text, checkbox_attr_name, variable, command): + (setting_box_frame, setting_box_frame_wrapper) = self._createSettingBoxFrame(parent_widget, for_var_label_text, for_var_desc_text) setting_box_checkbox_frame = CTkFrame(setting_box_frame_wrapper, corner_radius=0, width=0, height=0, fg_color=self.ctm.SB__BG_COLOR) setting_box_checkbox_frame.grid(row=0, column=1, padx=0, sticky="e") @@ -131,6 +130,7 @@ class _SettingBoxGenerator(): checkbox_height=self.uism.SB__CHECKBOX_SIZE, onvalue=True, offvalue=False, + variable=variable, command=command, corner_radius=self.uism.SB__CHECKBOX_CORNER_RADIUS, border_width=self.uism.SB__CHECKBOX_BORDER_WIDTH, @@ -144,7 +144,7 @@ class _SettingBoxGenerator(): ) setattr(self.config_window, checkbox_attr_name, checkbox_widget) - checkbox_widget.select() if is_checked else checkbox_widget.deselect() + # checkbox_widget.select() if is_checked else checkbox_widget.deselect() checkbox_widget.grid(row=0, column=0) @@ -155,8 +155,8 @@ class _SettingBoxGenerator(): - def createSettingBoxSlider(self, parent_widget, label_text, desc_text, slider_attr_name, slider_range, command, variable, slider_number_of_steps: Union[int, None] = None): - (setting_box_frame, setting_box_frame_wrapper) = self._createSettingBoxFrame(parent_widget, label_text, desc_text) + def createSettingBoxSlider(self, parent_widget, for_var_label_text, for_var_desc_text, slider_attr_name, slider_range, command, variable, slider_number_of_steps: Union[int, None] = None): + (setting_box_frame, setting_box_frame_wrapper) = self._createSettingBoxFrame(parent_widget, for_var_label_text, for_var_desc_text) setting_box_slider_frame = CTkFrame(setting_box_frame_wrapper, corner_radius=0, width=0, height=0, fg_color=self.ctm.SB__BG_COLOR) setting_box_slider_frame.grid(row=0, column=1, padx=0, sticky="e") @@ -181,18 +181,20 @@ class _SettingBoxGenerator(): def createSettingBoxProgressbarXSlider(self, - parent_widget, label_text, desc_text, command, + parent_widget, for_var_label_text, for_var_desc_text, command, entry_attr_name, - slider_attr_name, slider_range, slider_number_of_steps, + slider_attr_name, slider_range, progressbar_attr_name, passive_button_attr_name, passive_button_command, active_button_attr_name, active_button_command, button_image_filename, variable, + + slider_number_of_steps: Union[int, None] = None, ): - (setting_box_frame, setting_box_frame_wrapper) = self._createSettingBoxFrame(parent_widget, label_text, desc_text) + (setting_box_frame, setting_box_frame_wrapper) = self._createSettingBoxFrame(parent_widget, for_var_label_text, for_var_desc_text) setting_box_progressbar_x_slider_frame = CTkFrame(setting_box_frame_wrapper, corner_radius=0, width=0, height=0, fg_color=self.ctm.SB__BG_COLOR) setting_box_progressbar_x_slider_frame.grid(row=0, column=1, padx=0, sticky="e") @@ -288,8 +290,8 @@ class _SettingBoxGenerator(): - def createSettingBoxEntry(self, parent_widget, label_text, desc_text, entry_attr_name, entry_width, entry_bind__Any_KeyRelease, entry_textvariable): - (setting_box_frame, setting_box_frame_wrapper) = self._createSettingBoxFrame(parent_widget, label_text, desc_text) + def createSettingBoxEntry(self, parent_widget, for_var_label_text, for_var_desc_text, entry_attr_name, entry_width, entry_bind__Any_KeyRelease, entry_textvariable): + (setting_box_frame, setting_box_frame_wrapper) = self._createSettingBoxFrame(parent_widget, for_var_label_text, for_var_desc_text) setting_box_entry_frame = CTkFrame(setting_box_frame_wrapper, corner_radius=0, width=0, height=0, fg_color=self.ctm.SB__BG_COLOR) setting_box_entry_frame.grid(row=0, column=1, padx=0, sticky="e") @@ -414,50 +416,54 @@ class _SettingBoxGenerator(): - def createOption_DropdownMenu(self, setting_box_dropdown_menu_frame, optionmenu_attr_name, dropdown_menu_attr_name, dropdown_menu_values, command, variable): + def createOption_DropdownMenu(self, setting_box_dropdown_menu_frame, optionmenu_attr_name, command, variable, dropdown_menu_values): + + # set the value to the option menu's variable automatically + # def adjustedCommand(selected_value): + # option_menu_widget.set(selected_value) + # command(selected_value) + option_menu_widget = CTkOptionMenu( setting_box_dropdown_menu_frame, height=self.uism.SB__OPTIONMENU_HEIGHT, width=self.uism.SB__OPTIONMENU_WIDTH, + values=dropdown_menu_values, button_color=self.ctm.SB__OPTIONMENU_BG_COLOR, button_hover_color=self.ctm.SB__OPTIONMENU_HOVERED_BG_COLOR, fg_color=self.ctm.SB__OPTIONMENU_BG_COLOR, font=CTkFont(family=self.FONT_FAMILY, size=self.uism.SB__OPTION_MENU_FONT_SIZE, weight="normal"), variable=variable, + command=command, anchor="w", ) option_menu_widget.grid(row=0, column=0, sticky="e") setattr(self.config_window, optionmenu_attr_name, option_menu_widget) - # set the value to the option menu's variable automatically - def adjustedCommand(selected_value): - option_menu_widget.set(selected_value) - command(selected_value) + # option_menu_widget.configure(command=adjustedCommand) - dropdown_menu_widget = CTkScrollableDropdown( - option_menu_widget, - values=dropdown_menu_values, - justify="left", - width=self.uism.SB__DROPDOWN_MENU_WIDTH, - min_show_button_num=6, - button_pady=0, - frame_corner_radius=self.uism.SB__DROPDOWN_MENU_FRAME_CORNER_RADIUS, - max_button_height=self.uism.SB__DROPDOWN_MENU_MAX_BUTTON_HEIGHT, - max_height=self.uism.SB__DROPDOWN_MENU_FRAME_MAX_HEIGHT, - font=CTkFont(family=self.FONT_FAMILY, size=self.uism.SB__OPTION_MENU_FONT_SIZE, weight="normal"), - command=adjustedCommand, - ) + # dropdown_menu_widget = CTkScrollableDropdown( + # option_menu_widget, + # justify="left", + # width=self.uism.SB__DROPDOWN_MENU_WIDTH, + # min_show_button_num=6, + # button_pady=0, + # frame_corner_radius=self.uism.SB__DROPDOWN_MENU_FRAME_CORNER_RADIUS, + # max_button_height=self.uism.SB__DROPDOWN_MENU_MAX_BUTTON_HEIGHT, + # max_height=self.uism.SB__DROPDOWN_MENU_FRAME_MAX_HEIGHT, + # font=CTkFont(family=self.FONT_FAMILY, size=self.uism.SB__OPTION_MENU_FONT_SIZE, weight="normal"), + # command=adjustedCommand, + # ) # dropdown_menu_widget.bind( # "", # lambda e: dropdown_menu_widget._withdraw() if not str(e.widget).startswith(str(dropdown_menu_widget.frame._parent_frame)) else None, # ) - dropdown_menu_widget.bind( - "", - lambda e: print(e), - ) + # dropdown_menu_widget.bind( + # "", + # lambda e: print(e), + # ) - setattr(self.config_window, dropdown_menu_attr_name, dropdown_menu_widget) + # setattr(self.config_window, dropdown_menu_attr_name, dropdown_menu_widget) return option_menu_widget diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_advanced_settings/createSettingBox_AdvancedSettings.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_advanced_settings/createSettingBox_AdvancedSettings.py index 10fdb6f8..9a5397be 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_advanced_settings/createSettingBox_AdvancedSettings.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_advanced_settings/createSettingBox_AdvancedSettings.py @@ -20,12 +20,12 @@ def createSettingBox_AdvancedSettings(setting_box_wrapper, config_window, settin row=0 config_window.sb__ip_address = createSettingBoxEntry( parent_widget=setting_box_wrapper, - label_text="OSC IP Address", - desc_text="(Default: 127.0.0.1)", + for_var_label_text=config_window.view_variable.VAR_LABEL_OSC_IP_ADDRESS, + for_var_desc_text=config_window.view_variable.VAR_DESC_OSC_IP_ADDRESS, entry_attr_name="sb__entry_ip_address", entry_width=settings.uism.SB__ENTRY_WIDTH_150, entry_bind__Any_KeyRelease=lambda value: entry_ip_address_callback(value), - entry_textvariable=StringVar(value=config.OSC_IP_ADDRESS), + entry_textvariable=config_window.view_variable.VAR_OSC_IP_ADDRESS, ) config_window.sb__ip_address.grid(row=row) row+=1 @@ -33,12 +33,12 @@ def createSettingBox_AdvancedSettings(setting_box_wrapper, config_window, settin config_window.sb__port = createSettingBoxEntry( parent_widget=setting_box_wrapper, - label_text="OSC Port", - desc_text="(Default: 9000)", + for_var_label_text=config_window.view_variable.VAR_LABEL_OSC_PORT, + for_var_desc_text=config_window.view_variable.VAR_DESC_OSC_PORT, entry_attr_name="sb__entry_port", entry_width=settings.uism.SB__ENTRY_WIDTH_150, entry_bind__Any_KeyRelease=lambda value: entry_port_callback(value), - entry_textvariable=IntVar(value=config.OSC_PORT), + entry_textvariable=config_window.view_variable.VAR_OSC_PORT, ) config_window.sb__port.grid(row=row) - row+=1 \ No newline at end of file + row+=1 diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_appearance/createSettingBox_Appearance.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_appearance/createSettingBox_Appearance.py index fc9567ba..f44f18ce 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_appearance/createSettingBox_Appearance.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_appearance/createSettingBox_Appearance.py @@ -1,7 +1,4 @@ -from customtkinter import StringVar, IntVar -from tkinter import font as tk_font -from languages import selectable_languages -from utils import get_key_by_value, callFunctionIfCallable +from utils import callFunctionIfCallable from .._SettingBoxGenerator import _SettingBoxGenerator @@ -24,22 +21,21 @@ def createSettingBox_Appearance(setting_box_wrapper, config_window, settings): callFunctionIfCallable(config_window.CALLBACK_SET_UI_SCALING, value) def optionmenu_font_family_callback(value): - callFunctionIfCallable(config_window.CALLBACK_SET_FONT_FAMILY, value) + callFunctionIfCallable(config_window.view_variable.CALLBACK_SET_FONT_FAMILY, value) def optionmenu_ui_language_callback(value): - value = get_key_by_value(selectable_languages, value) callFunctionIfCallable(config_window.CALLBACK_SET_UI_LANGUAGE, value) row=0 config_window.sb__transparency = createSettingBoxSlider( parent_widget=setting_box_wrapper, - label_text="Transparency", - desc_text="Change the window's transparency. 50% to 100%. (Default: 100%)", + for_var_label_text=config_window.view_variable.VAR_LABEL_TRANSPARENCY, + for_var_desc_text=config_window.view_variable.VAR_DESC_TRANSPARENCY, slider_attr_name="sb__transparency_slider", - slider_range=(50, 100), + slider_range=config_window.view_variable.SLIDER_RANGE_TRANSPARENCY, command=lambda value: slider_transparency_callback(value), - variable=IntVar(value=config.TRANSPARENCY), + variable=config_window.view_variable.VAR_TRANSPARENCY, ) config_window.sb__transparency.grid(row=row) row+=1 @@ -47,58 +43,55 @@ def createSettingBox_Appearance(setting_box_wrapper, config_window, settings): config_window.sb__appearance_theme = createSettingBoxDropdownMenu( parent_widget=setting_box_wrapper, - label_text="Theme", - desc_text="Change the color theme from \"Light\" and \"Dark\". If you select \"System\", It will adjust based on your Windows theme. (Default: System)", + for_var_label_text=config_window.view_variable.VAR_LABEL_APPEARANCE_THEME, + for_var_desc_text=config_window.view_variable.VAR_DESC_APPEARANCE_THEME, optionmenu_attr_name="sb__optionmenu_appearance_theme", dropdown_menu_attr_name="sb__dropdown_appearance_theme", - dropdown_menu_values=["Light", "Dark", "System"], + dropdown_menu_values=config_window.view_variable.LIST_APPEARANCE_THEME, command=lambda value: optionmenu_appearance_theme_callback(value), - variable=StringVar(value=config.APPEARANCE_THEME) + variable=config_window.view_variable.VAR_APPEARANCE_THEME, ) config_window.sb__appearance_theme.grid(row=row) row+=1 + config_window.sb__ui_scaling = createSettingBoxDropdownMenu( parent_widget=setting_box_wrapper, - label_text="UI Size", - desc_text="(Default: 100%)", + for_var_label_text=config_window.view_variable.VAR_LABEL_UI_SCALING, + for_var_desc_text=config_window.view_variable.VAR_DESC_UI_SCALING, optionmenu_attr_name="sb__optionmenu_ui_scaling", dropdown_menu_attr_name="sb__dropdown_ui_scaling", - dropdown_menu_values=["80%", "90%", "100%", "110%", "120%"], + dropdown_menu_values=config_window.view_variable.LIST_UI_SCALING, command=lambda value: optionmenu_ui_scaling_callback(value), - variable=StringVar(value=config.UI_SCALING) + variable=config_window.view_variable.VAR_UI_SCALING, ) config_window.sb__ui_scaling.grid(row=row) row+=1 - # font_families = list(tk_font.families()) config_window.sb__font_family = createSettingBoxDropdownMenu( parent_widget=setting_box_wrapper, - label_text="Font Family", - desc_text="(Default: Yu Gothic UI)", + for_var_label_text=config_window.view_variable.VAR_LABEL_FONT_FAMILY, + for_var_desc_text=config_window.view_variable.VAR_DESC_FONT_FAMILY, optionmenu_attr_name="sb__optionmenu_font_family", - dropdown_menu_attr_name="sb__dropdown_font_family", - dropdown_menu_values=["Font A", "Font B"], - # dropdown_menu_values=font_families, + dropdown_menu_values=config_window.view_variable.LIST_FONT_FAMILY, command=lambda value: optionmenu_font_family_callback(value), - variable=StringVar(value=config.FONT_FAMILY) + variable=config_window.view_variable.VAR_FONT_FAMILY, ) config_window.sb__font_family.grid(row=row) row+=1 - selectable_languages_values = list(selectable_languages.values()) config_window.sb__ui_language = createSettingBoxDropdownMenu( parent_widget=setting_box_wrapper, - label_text="UI Language", - desc_text="(Default: English)", + for_var_label_text=config_window.view_variable.VAR_LABEL_UI_LANGUAGE, + for_var_desc_text=config_window.view_variable.VAR_DESC_UI_LANGUAGE, optionmenu_attr_name="sb__optionmenu_ui_language", dropdown_menu_attr_name="sb__dropdown_ui_language", - dropdown_menu_values=selectable_languages_values, + dropdown_menu_values=config_window.view_variable.LIST_UI_LANGUAGE, command=lambda value: optionmenu_ui_language_callback(value), - variable=StringVar(value=selectable_languages[config.UI_LANGUAGE]), + variable=config_window.view_variable.VAR_UI_LANGUAGE, ) config_window.sb__ui_language.grid(row=row) row+=1 \ No newline at end of file diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/createSettingBox_Others.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/createSettingBox_Others.py index 7b5811c9..42f7d295 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/createSettingBox_Others.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/createSettingBox_Others.py @@ -26,11 +26,11 @@ def createSettingBox_Others(setting_box_wrapper, config_window, settings): row=0 config_window.sb__auto_clear_message_box = createSettingBoxCheckbox( parent_widget=setting_box_wrapper, - label_text="Auto Clear The Message Box", - desc_text="Clear the message box after sending your message.", + for_var_label_text=config_window.view_variable.VAR_LABEL_ENABLE_AUTO_CLEAR_MESSAGE_BOX, + for_var_desc_text=config_window.view_variable.VAR_DESC_ENABLE_AUTO_CLEAR_MESSAGE_BOX, checkbox_attr_name="sb__checkbox_auto_clear_message_box", command=lambda: checkbox_auto_clear_message_box_callback(config_window.sb__checkbox_auto_clear_message_box), - is_checked=False + variable=config_window.view_variable.VAR_ENABLE_AUTO_CLEAR_MESSAGE_BOX, ) config_window.sb__auto_clear_message_box.grid(row=row) row+=1 @@ -38,11 +38,11 @@ def createSettingBox_Others(setting_box_wrapper, config_window, settings): config_window.sb__notice_xsoverlay = createSettingBoxCheckbox( parent_widget=setting_box_wrapper, - label_text="Notification XSOverlay (VR Only)", - desc_text="Notify received messages by using XSOverlay's notification feature.", + for_var_label_text=config_window.view_variable.VAR_LABEL_ENABLE_NOTICE_XSOVERLAY, + for_var_desc_text=config_window.view_variable.VAR_DESC_ENABLE_NOTICE_XSOVERLAY, checkbox_attr_name="sb__checkbox_notice_xsoverlay", command=lambda: checkbox_notice_xsoverlay_callback(config_window.sb__checkbox_notice_xsoverlay), - is_checked=False + variable=config_window.view_variable.VAR_ENABLE_NOTICE_XSOVERLAY, ) config_window.sb__notice_xsoverlay.grid(row=row) row+=1 @@ -50,12 +50,12 @@ def createSettingBox_Others(setting_box_wrapper, config_window, settings): config_window.sb__message_format = createSettingBoxEntry( parent_widget=setting_box_wrapper, - label_text="Message Format", - desc_text="You can change the decoration of the message you want to send. (Default: \"[message]([translation])\" )", + for_var_label_text=config_window.view_variable.VAR_LABEL_MESSAGE_FORMAT, + for_var_desc_text=config_window.view_variable.VAR_DESC_MESSAGE_FORMAT, entry_attr_name="sb__entry_message_format", entry_width=settings.uism.SB__ENTRY_WIDTH_250, entry_bind__Any_KeyRelease=lambda value: entry_message_format_callback(value), - entry_textvariable=StringVar(value=config.MESSAGE_FORMAT), + entry_textvariable=config_window.view_variable.VAR_MESSAGE_FORMAT, ) config_window.sb__message_format.grid(row=row) row+=1 \ No newline at end of file diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_transcription/createSettingBox_Mic.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_transcription/createSettingBox_Mic.py index e4e550c2..6ff16118 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_transcription/createSettingBox_Mic.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_transcription/createSettingBox_Mic.py @@ -6,7 +6,6 @@ from utils import callFunctionIfCallable from .._SettingBoxGenerator import _SettingBoxGenerator -from config import config def createSettingBox_Mic(setting_box_wrapper, config_window, settings): sbg = _SettingBoxGenerator(config_window, settings) @@ -69,28 +68,25 @@ def createSettingBox_Mic(setting_box_wrapper, config_window, settings): # Mic Host と Mic Device は一つの項目として引っ付ける予定 config_window.sb__mic_host = createSettingBoxDropdownMenu( parent_widget=setting_box_wrapper, - label_text="Mic Host", - desc_text="Select the mic host. (Default: ?)", + for_var_label_text=config_window.view_variable.VAR_LABEL_MIC_HOST, + for_var_desc_text=config_window.view_variable.VAR_DESC_MIC_HOST, optionmenu_attr_name="sb__optionmenu_mic_host", - dropdown_menu_attr_name="sb__dropdown_mic_host", - # dropdown_menu_values=model.getListInputHost(), - dropdown_menu_values=["host1", "host2", "host3"], + dropdown_menu_values=config_window.view_variable.LIST_MIC_HOST, command=lambda value: optionmenu_mic_host_callback(value), - variable=StringVar(value=config.CHOICE_MIC_HOST) + variable=config_window.view_variable.VAR_MIC_HOST, ) config_window.sb__mic_host.grid(row=row) row+=1 config_window.sb__mic_device = createSettingBoxDropdownMenu( parent_widget=setting_box_wrapper, - label_text="Mic Device", - desc_text="Select the mic devise. (Default: ?)", + for_var_label_text=config_window.view_variable.VAR_LABEL_MIC_DEVICE, + for_var_desc_text=config_window.view_variable.VAR_DESC_MIC_DEVICE, optionmenu_attr_name="sb__optionmenu_mic_device", dropdown_menu_attr_name="sb__dropdown_mic_device", - # dropdown_menu_values=model.getListInputDevice(), - dropdown_menu_values=["device1", "device2", "device3"], + dropdown_menu_values=config_window.view_variable.LIST_MIC_DEVICE, command=lambda value: optionmenu_input_mic_device_callback(value), - variable=StringVar(value=config.CHOICE_MIC_DEVICE) + variable=config_window.view_variable.VAR_MIC_DEVICE, ) config_window.sb__mic_device.grid(row=row) row+=1 @@ -98,16 +94,15 @@ def createSettingBox_Mic(setting_box_wrapper, config_window, settings): config_window.sb__mic_energy_threshold = createSettingBoxProgressbarXSlider( parent_widget=setting_box_wrapper, - label_text="Mic Energy Threshold", - desc_text="Slider to modify the threshold for activating voice input.\nPress the microphone button to start input and speak something, so you can adjust it while monitoring the actual volume. 0 to 2000 (Default: 300)", + for_var_label_text=config_window.view_variable.VAR_LABEL_MIC_ENERGY_THRESHOLD, + for_var_desc_text=config_window.view_variable.VAR_DESC_MIC_ENERGY_THRESHOLD, command=slider_input_mic_energy_threshold_callback, - variable=IntVar(value=config.INPUT_MIC_ENERGY_THRESHOLD), + variable=config_window.view_variable.VAR_MIC_ENERGY_THRESHOLD, entry_attr_name="sb__progressbar_x_slider__entry_mic_energy_threshold", slider_attr_name="progressbar_x_slider__slider_mic_energy_threshold", - slider_range=(0, config.MAX_MIC_ENERGY_THRESHOLD), - slider_number_of_steps=config.MAX_MIC_ENERGY_THRESHOLD, + slider_range=config_window.view_variable.SLIDER_RANGE_MIC_ENERGY_THRESHOLD, progressbar_attr_name="sb__progressbar_x_slider__progressbar_mic_energy_threshold", @@ -133,11 +128,11 @@ def createSettingBox_Mic(setting_box_wrapper, config_window, settings): # Mic Dynamic Energy Thresholdも上に引っ付ける予定 config_window.sb__mic_dynamic_energy_threshold = createSettingBoxCheckbox( parent_widget=setting_box_wrapper, - label_text="Mic Dynamic Energy Threshold", - desc_text="When this feature is selected, it will automatically adjust in a way that works well, based on the set Mic Energy Threshold.", + for_var_label_text=config_window.view_variable.VAR_LABEL_MIC_DYNAMIC_ENERGY_THRESHOLD, + for_var_desc_text=config_window.view_variable.VAR_DESC_MIC_DYNAMIC_ENERGY_THRESHOLD, checkbox_attr_name="sb__checkbox_mic_dynamic_energy_threshold", command=lambda: checkbox_input_mic_dynamic_energy_threshold_callback(config_window.sb__checkbox_mic_dynamic_energy_threshold), - is_checked=False + variable=config_window.view_variable.VAR_MIC_DYNAMIC_ENERGY_THRESHOLD ) config_window.sb__mic_dynamic_energy_threshold.grid(row=row) row+=1 @@ -146,55 +141,50 @@ def createSettingBox_Mic(setting_box_wrapper, config_window, settings): # 以下3つも一つの項目にまとめるかもしれない config_window.sb__mic_record_timeout = createSettingBoxEntry( parent_widget=setting_box_wrapper, - label_text="Mic Record Timeout", - desc_text="(Default: 3)", + for_var_label_text=config_window.view_variable.VAR_LABEL_MIC_RECORD_TIMEOUT, + for_var_desc_text=config_window.view_variable.VAR_DESC_MIC_RECORD_TIMEOUT, entry_attr_name="sb__entry_mic_record_timeout", entry_width=settings.uism.SB__ENTRY_WIDTH_100, entry_bind__Any_KeyRelease=lambda value: entry_input_mic_record_timeout_callback(value), - entry_textvariable=IntVar(value=config.INPUT_MIC_RECORD_TIMEOUT), + entry_textvariable=config_window.view_variable.VAR_MIC_RECORD_TIMEOUT, ) config_window.sb__mic_record_timeout.grid(row=row) row+=1 config_window.sb__mic_phrase_timeout = createSettingBoxEntry( parent_widget=setting_box_wrapper, - label_text="Mic Phrase Timeout", - desc_text="It will stop recording and send the recordings when the set second(s) is reached. (Default: 3)", + for_var_label_text=config_window.view_variable.VAR_LABEL_MIC_PHRASE_TIMEOUT, + for_var_desc_text=config_window.view_variable.VAR_DESC_MIC_PHRASE_TIMEOUT, entry_attr_name="sb__entry_mic_phrase_timeout", entry_width=settings.uism.SB__ENTRY_WIDTH_100, entry_bind__Any_KeyRelease=lambda value: entry_input_mic_phrase_timeout_callback(value), - entry_textvariable=IntVar(value=config.INPUT_MIC_PHRASE_TIMEOUT), + entry_textvariable=config_window.view_variable.VAR_MIC_PHRASE_TIMEOUT, ) config_window.sb__mic_phrase_timeout.grid(row=row) row+=1 config_window.sb__mic_max_phrases = createSettingBoxEntry( parent_widget=setting_box_wrapper, - label_text="Mic Max Phrases", - desc_text="It will stop recording and send the recordings when the set count of phrase(s) is reached. (Default: 10)", + for_var_label_text=config_window.view_variable.VAR_LABEL_MIC_MAX_PHRASES, + for_var_desc_text=config_window.view_variable.VAR_DESC_MIC_MAX_PHRASES, entry_attr_name="sb__entry_mic_max_phrases", entry_width=settings.uism.SB__ENTRY_WIDTH_100, entry_bind__Any_KeyRelease=lambda value: entry_input_mic_max_phrases_callback(value), - entry_textvariable=IntVar(value=config.INPUT_MIC_MAX_PHRASES), + entry_textvariable=config_window.view_variable.VAR_MIC_MAX_PHRASES, ) config_window.sb__mic_max_phrases.grid(row=row) row+=1 - # __________ + # # __________ - - if len(config.INPUT_MIC_WORD_FILTER) > 0: - entry_textvariable=StringVar(value=",".join(config.INPUT_MIC_WORD_FILTER)) - else: - entry_textvariable=None config_window.sb__mic_word_filter = createSettingBoxEntry( parent_widget=setting_box_wrapper, - label_text="Mic Word Filter", - desc_text="It will not send the sentence if the word(s) included in the set list of words.\nHow to set: e.g. AAA,BBB,CCC", + for_var_label_text=config_window.view_variable.VAR_LABEL_MIC_WORD_FILTER, + for_var_desc_text=config_window.view_variable.VAR_DESC_MIC_WORD_FILTER, entry_attr_name="sb__entry_mic_word_filter", - entry_width=settings.uism.SB__ENTRY_WIDTH_100, + entry_width=settings.uism.SB__ENTRY_WIDTH_300, entry_bind__Any_KeyRelease=lambda value: entry_input_mic_word_filters_callback(value), - entry_textvariable=entry_textvariable, + entry_textvariable=config_window.view_variable.VAR_MIC_WORD_FILTER, ) config_window.sb__mic_word_filter.grid(row=row) row+=1 \ No newline at end of file diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_transcription/createSettingBox_Speaker.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_transcription/createSettingBox_Speaker.py index a4237b82..f0da5ab4 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_transcription/createSettingBox_Speaker.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_transcription/createSettingBox_Speaker.py @@ -63,14 +63,13 @@ def createSettingBox_Speaker(setting_box_wrapper, config_window, settings): row=0 config_window.sb__speaker_device = createSettingBoxDropdownMenu( parent_widget=setting_box_wrapper, - label_text="Speaker Device", - desc_text="Select the speaker devise. (Default: ?)", + for_var_label_text=config_window.view_variable.VAR_LABEL_SPEAKER_DEVICE, + for_var_desc_text=config_window.view_variable.VAR_DESC_SPEAKER_DEVICE, optionmenu_attr_name="sb__optionmenu_speaker_device", dropdown_menu_attr_name="sb__dropdown_speaker_device", - # dropdown_menu_values=model.getListOutputDevice(), - dropdown_menu_values=["device1", "device2", "device3"], + dropdown_menu_values=config_window.view_variable.LIST_SPEAKER_DEVICE, command=lambda value: optionmenu_input_speaker_device_callback(value), - variable=StringVar(value=config.CHOICE_SPEAKER_DEVICE) + variable=config_window.view_variable.VAR_SPEAKER_DEVICE, ) config_window.sb__speaker_device.grid(row=row) row+=1 @@ -78,16 +77,15 @@ def createSettingBox_Speaker(setting_box_wrapper, config_window, settings): config_window.sb__speaker_energy_threshold = createSettingBoxProgressbarXSlider( parent_widget=setting_box_wrapper, - label_text="Speaker Energy Threshold", - desc_text="Slider to modify the threshold for activating voice input.\nPress the headphones mark button to start input and speak something, so you can adjust it while monitoring the actual volume. 0 to 4000 (Default: 300)", + for_var_label_text=config_window.view_variable.VAR_LABEL_SPEAKER_ENERGY_THRESHOLD, + for_var_desc_text=config_window.view_variable.VAR_DESC_SPEAKER_ENERGY_THRESHOLD, command=slider_input_speaker_energy_threshold_callback, - variable=IntVar(value=config.INPUT_SPEAKER_ENERGY_THRESHOLD), + variable=config_window.view_variable.VAR_SPEAKER_ENERGY_THRESHOLD, entry_attr_name="sb__progressbar_x_slider__entry_speaker_energy_threshold", slider_attr_name="progressbar_x_slider__slider_speaker_energy_threshold", - slider_range=(0, config.MAX_SPEAKER_ENERGY_THRESHOLD), - slider_number_of_steps=config.MAX_SPEAKER_ENERGY_THRESHOLD, + slider_range=config_window.view_variable.SLIDER_RANGE_SPEAKER_ENERGY_THRESHOLD, progressbar_attr_name="sb__progressbar_x_slider__progressbar_speaker_energy_threshold", @@ -113,11 +111,11 @@ def createSettingBox_Speaker(setting_box_wrapper, config_window, settings): # Speaker Dynamic Energy Thresholdも上に引っ付ける予定 config_window.sb__speaker_dynamic_energy_threshold = createSettingBoxCheckbox( parent_widget=setting_box_wrapper, - label_text="Speaker Dynamic Energy Threshold", - desc_text="When this feature is selected, it will automatically adjust in a way that works well, based on the set Speaker Energy Threshold.", + for_var_label_text=config_window.view_variable.VAR_LABEL_SPEAKER_DYNAMIC_ENERGY_THRESHOLD, + for_var_desc_text=config_window.view_variable.VAR_DESC_SPEAKER_DYNAMIC_ENERGY_THRESHOLD, checkbox_attr_name="sb__checkbox_speaker_dynamic_energy_threshold", command=lambda: checkbox_input_speaker_dynamic_energy_threshold_callback(config_window.sb__checkbox_speaker_dynamic_energy_threshold), - is_checked=False + variable=config_window.view_variable.VAR_MIC_DYNAMIC_ENERGY_THRESHOLD, ) config_window.sb__speaker_dynamic_energy_threshold.grid(row=row) row+=1 @@ -126,36 +124,36 @@ def createSettingBox_Speaker(setting_box_wrapper, config_window, settings): # 以下3つも一つの項目にまとめるかもしれない config_window.sb__speaker_record_timeout = createSettingBoxEntry( parent_widget=setting_box_wrapper, - label_text="Speaker Record Timeout", - desc_text="(Default: 3)", + for_var_label_text=config_window.view_variable.VAR_LABEL_SPEAKER_RECORD_TIMEOUT, + for_var_desc_text=config_window.view_variable.VAR_DESC_SPEAKER_RECORD_TIMEOUT, entry_attr_name="sb__entry_speaker_record_timeout", entry_width=settings.uism.SB__ENTRY_WIDTH_100, entry_bind__Any_KeyRelease=lambda value: entry_input_speaker_record_timeout_callback(value), - entry_textvariable=IntVar(value=config.INPUT_SPEAKER_RECORD_TIMEOUT), + entry_textvariable=config_window.view_variable.VAR_SPEAKER_RECORD_TIMEOUT, ) config_window.sb__speaker_record_timeout.grid(row=row) row+=1 config_window.sb__speaker_phrase_timeout = createSettingBoxEntry( parent_widget=setting_box_wrapper, - label_text="Speaker Phrase Timeout", - desc_text="It will stop recording and receive the recordings when the set second(s) is reached. (Default: 3)", + for_var_label_text=config_window.view_variable.VAR_LABEL_SPEAKER_PHRASE_TIMEOUT, + for_var_desc_text=config_window.view_variable.VAR_DESC_SPEAKER_PHRASE_TIMEOUT, entry_attr_name="sb__entry_speaker_phrase_timeout", entry_width=settings.uism.SB__ENTRY_WIDTH_100, entry_bind__Any_KeyRelease=lambda value: entry_input_speaker_phrase_timeout_callback(value), - entry_textvariable=IntVar(value=config.INPUT_SPEAKER_PHRASE_TIMEOUT), + entry_textvariable=config_window.view_variable.VAR_SPEAKER_PHRASE_TIMEOUT, ) config_window.sb__speaker_phrase_timeout.grid(row=row) row+=1 config_window.sb__speaker_max_phrases = createSettingBoxEntry( parent_widget=setting_box_wrapper, - label_text="Speaker Max Phrases", - desc_text="It will stop recording and receive the recordings when the set count of phrase(s) is reached. (Default: 10)", + for_var_label_text=config_window.view_variable.VAR_LABEL_SPEAKER_MAX_PHRASES, + for_var_desc_text=config_window.view_variable.VAR_DESC_SPEAKER_MAX_PHRASES, entry_attr_name="sb__entry_speaker_max_phrases", entry_width=settings.uism.SB__ENTRY_WIDTH_100, entry_bind__Any_KeyRelease=lambda value: entry_input_speaker_max_phrases_callback(value), - entry_textvariable=IntVar(value=config.INPUT_SPEAKER_MAX_PHRASES), + entry_textvariable=config_window.view_variable.VAR_SPEAKER_MAX_PHRASES, ) config_window.sb__speaker_max_phrases.grid(row=row) row+=1 diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_translation/createSettingBox_Translation.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_translation/createSettingBox_Translation.py index 5c635edd..45d341d4 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_translation/createSettingBox_Translation.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_translation/createSettingBox_Translation.py @@ -18,12 +18,12 @@ def createSettingBox_Translation(setting_box_wrapper, config_window, settings): row=0 config_window.sb__deepl_authkey = createSettingBoxEntry( parent_widget=setting_box_wrapper, - label_text="DeepL Auth Key", - desc_text="", + for_var_label_text=config_window.view_variable.VAR_LABEL_DEEPL_AUTH_KEY, + for_var_desc_text=config_window.view_variable.VAR_DESC_DEEPL_AUTH_KEY, entry_attr_name="sb__deepl_authkey", entry_width=settings.uism.SB__ENTRY_WIDTH_300, entry_bind__Any_KeyRelease=lambda value: deepl_authkey_callback(value), - entry_textvariable=StringVar(value=config.AUTH_KEYS["DeepL(auth)"]), + entry_textvariable=config_window.view_variable.VAR_DEEPL_AUTH_KEY, ) config_window.sb__deepl_authkey.grid(row=row) row+=1 \ No newline at end of file diff --git a/vrct_gui/main_window/createMainWindowWidgets.py b/vrct_gui/main_window/createMainWindowWidgets.py index 980a15be..2949a7e7 100644 --- a/vrct_gui/main_window/createMainWindowWidgets.py +++ b/vrct_gui/main_window/createMainWindowWidgets.py @@ -5,7 +5,7 @@ from customtkinter import CTkFrame from ..ui_utils import createButtonWithImage, getImagePath -def createMainWindowWidgets(vrct_gui, settings): +def createMainWindowWidgets(vrct_gui, settings, view_variable): vrct_gui.protocol("WM_DELETE_WINDOW", vrct_gui.quitVRCT) # self.IS_DEVELOPER_MODE = False diff --git a/vrct_gui/vrct_gui.py b/vrct_gui/vrct_gui.py index 7468b3b9..836ca7c5 100644 --- a/vrct_gui/vrct_gui.py +++ b/vrct_gui/vrct_gui.py @@ -16,7 +16,7 @@ from .ui_utils import _setDefaultActiveTab class VRCT_GUI(CTk): def __init__(self): super().__init__() - self.settings = SimpleNamespace() + # self.settings = SimpleNamespace() self.YOUR_LANGUAGE = "Japanese\n(Japan)" self.TARGET_LANGUAGE = "English\n(United States)" @@ -29,11 +29,12 @@ class VRCT_GUI(CTk): self.CALLBACK_SELECTED_TAB_NO_3 = None - def createGUI(self, settings): + def createGUI(self, settings, view_variable): self.settings = settings + self.view_variable = view_variable - createMainWindowWidgets(vrct_gui=self, settings=self.settings.main) - self.config_window = ConfigWindow(vrct_gui=self, settings=self.settings.config_window) + createMainWindowWidgets(vrct_gui=self, settings=self.settings.main, view_variable=self.view_variable) + self.config_window = ConfigWindow(vrct_gui=self, settings=self.settings.config_window, view_variable=self.view_variable) # self.information_window = ToplevelWindowInformation(self) def startMainLoop(self):