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 1/6] =?UTF-8?q?Config=20Window=20=E5=90=84=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E9=A0=85=E7=9B=AE=E3=82=92=E5=A4=89=E6=95=B0=E5=8C=96?= =?UTF-8?q?=E3=81=97=E3=80=81ctk=20variable=E3=81=AA=E3=81=A9=E5=85=A8?= =?UTF-8?q?=E3=81=A6view.py=E3=81=AB=E7=A7=BB=E5=8B=95=E3=80=82=20vrct=5Fg?= =?UTF-8?q?ui=E4=BB=A5=E4=B8=8B=E3=81=A7=E3=81=AFconfig.py=E3=82=92?= =?UTF-8?q?=E4=BD=BF=E3=82=8F=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E5=88=87=E3=82=8A=E9=9B=A2=E3=81=97=E3=81=9F=E3=80=82=20CTkScr?= =?UTF-8?q?ollableDropdown=E3=82=92=E4=BD=BF=E3=81=86=E3=81=93=E3=81=A8?= =?UTF-8?q?=E3=82=92=E3=82=84=E3=82=81=E3=81=9F=E3=80=82(grab=5Fset?= =?UTF-8?q?=E3=81=A8=E5=B9=B2=E6=B8=89=E3=81=99=E3=82=8B=E3=81=9F=E3=82=81?= =?UTF-8?q?)?= 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): From a4507eea182ec2f86b3ba97ec9b19a23421fce53 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Sat, 2 Sep 2023 02:36:17 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[Chore]=20Config=20Window:=20config.py,=20C?= =?UTF-8?q?TkScrollableDropdown=E3=81=AEimport=E6=96=87=E3=82=92=E5=89=8A?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../setting_box_containers/_SettingBoxGenerator.py | 4 +--- .../createSettingBox_AdvancedSettings.py | 4 ---- .../setting_box_appearance/createSettingBox_Appearance.py | 2 -- .../setting_box_others/createSettingBox_Others.py | 4 ---- .../setting_box_transcription/createSettingBox_Mic.py | 3 --- .../setting_box_transcription/createSettingBox_Speaker.py | 4 ---- .../setting_box_translation/createSettingBox_Translation.py | 4 ---- 7 files changed, 1 insertion(+), 24 deletions(-) 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 d6044900..3f91fa48 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,11 +1,9 @@ -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 customtkinter import CTkOptionMenu, CTkFont, CTkFrame, CTkLabel, CTkRadioButton, CTkEntry, CTkSlider, CTkSwitch, CTkCheckBox, CTkProgressBar, END as CTK_END from vrct_gui.ui_utils import createButtonWithImage from typing import Union - class _SettingBoxGenerator(): def __init__(self, config_window, settings): 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 9a5397be..41c57907 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 @@ -1,11 +1,7 @@ -from customtkinter import StringVar, IntVar - from utils import callFunctionIfCallable from .._SettingBoxGenerator import _SettingBoxGenerator -from config import config - def createSettingBox_AdvancedSettings(setting_box_wrapper, config_window, settings): sbg = _SettingBoxGenerator(config_window, settings) createSettingBoxEntry = sbg.createSettingBoxEntry 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 f44f18ce..800288a2 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 @@ -2,8 +2,6 @@ from utils import callFunctionIfCallable from .._SettingBoxGenerator import _SettingBoxGenerator -from config import config - def createSettingBox_Appearance(setting_box_wrapper, config_window, settings): sbg = _SettingBoxGenerator(config_window, settings) createSettingBoxDropdownMenu = sbg.createSettingBoxDropdownMenu 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 42f7d295..b3c2b81e 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 @@ -1,11 +1,7 @@ -from customtkinter import StringVar, IntVar - from utils import callFunctionIfCallable from .._SettingBoxGenerator import _SettingBoxGenerator -from config import config - def createSettingBox_Others(setting_box_wrapper, config_window, settings): sbg = _SettingBoxGenerator(config_window, settings) createSettingBoxCheckbox = sbg.createSettingBoxCheckbox 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 6ff16118..583d192f 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 @@ -1,12 +1,9 @@ from time import sleep -from customtkinter import StringVar, IntVar - from utils import callFunctionIfCallable from .._SettingBoxGenerator import _SettingBoxGenerator - def createSettingBox_Mic(setting_box_wrapper, config_window, settings): sbg = _SettingBoxGenerator(config_window, settings) createSettingBoxDropdownMenu = sbg.createSettingBoxDropdownMenu 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 f0da5ab4..236e4c58 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 @@ -1,13 +1,9 @@ from time import sleep -from customtkinter import StringVar, IntVar - from utils import callFunctionIfCallable from .._SettingBoxGenerator import _SettingBoxGenerator -from config import config - def createSettingBox_Speaker(setting_box_wrapper, config_window, settings): sbg = _SettingBoxGenerator(config_window, settings) createSettingBoxDropdownMenu = sbg.createSettingBoxDropdownMenu 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 45d341d4..1bdaa8b0 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 @@ -1,11 +1,7 @@ -from customtkinter import StringVar, IntVar - from utils import callFunctionIfCallable from .._SettingBoxGenerator import _SettingBoxGenerator -from config import config - def createSettingBox_Translation(setting_box_wrapper, config_window, settings): sbg = _SettingBoxGenerator(config_window, settings) createSettingBoxEntry = sbg.createSettingBoxEntry From 66413a60dd172b9fd6c8a14afdeaefb5681546e6 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Sat, 2 Sep 2023 02:46:27 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[Chore]=20view.py=E3=81=AE=E5=A4=89?= =?UTF-8?q?=E6=95=B0=E7=BE=A4=E3=81=AB=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B=E3=81=AA=E3=81=A9?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view.py | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/view.py b/view.py index 5f37da6a..248a8f3b 100644 --- a/view.py +++ b/view.py @@ -37,6 +37,8 @@ class View(): ) self.view_variable = SimpleNamespace( + # Config Window + # Appearance Tab 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), @@ -68,7 +70,7 @@ class View(): VAR_UI_LANGUAGE=StringVar(value=selectable_languages[config.UI_LANGUAGE]), - + # Translation Tab VAR_LABEL_DEEPL_AUTH_KEY=StringVar(value="DeepL Auth Key"), VAR_DESC_DEEPL_AUTH_KEY=None, # VAR_DESC_DEEPL_AUTH_KEY=StringVar(value=""), @@ -76,7 +78,7 @@ class View(): VAR_DEEPL_AUTH_KEY=StringVar(value=config.AUTH_KEYS["DeepL(auth)"]), - + # Transcription Tab (Mic) VAR_LABEL_MIC_HOST=StringVar(value="Mic Host"), VAR_DESC_MIC_HOST=StringVar(value="Select the mic host. (Default: ?)"), LIST_MIC_HOST=[], # model.getListInputHost(), @@ -115,22 +117,13 @@ class View(): 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 ""), - - - - - - - - - + # Transcription Tab (Speaker) VAR_LABEL_SPEAKER_DEVICE=StringVar(value="Speaker Device"), VAR_DESC_SPEAKER_DEVICE=StringVar(value="Select the speaker devise. (Default: ?)"), LIST_SPEAKER_DEVICE=[], # model.getListOutputDevice(), @@ -164,10 +157,7 @@ class View(): VAR_SPEAKER_MAX_PHRASES=IntVar(value=config.INPUT_SPEAKER_MAX_PHRASES), - - - - + # Others Tab 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, @@ -184,9 +174,7 @@ class View(): VAR_MESSAGE_FORMAT=StringVar(value=config.MESSAGE_FORMAT), - - - + # Advanced Settings Tab 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, @@ -196,7 +184,6 @@ class View(): VAR_DESC_OSC_PORT=StringVar(value="(Default: 9000)"), CALLBACK_SET_OSC_PORT=None, VAR_OSC_PORT=IntVar(value=config.OSC_PORT), - ) From cc94added0b22fa1f58093f61740c89cf447d9bd Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Sat, 2 Sep 2023 03:42:06 +0900 Subject: [PATCH 4/6] =?UTF-8?q?Main=20Window:=20Sidebar=20features?= =?UTF-8?q?=E7=B3=BB=E3=81=AECALLBACK=E5=A4=89=E6=95=B0=E3=82=92view.py?= =?UTF-8?q?=E3=81=AB=E7=A7=BB=E5=8B=95=E3=80=82=E5=87=A6=E7=90=86=E3=82=82?= =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF=E3=82=BF=E3=83=AA=E3=83=B3?= =?UTF-8?q?=E3=82=B0=E3=80=82=20=E3=81=9D=E3=81=AECALLBACK=E9=96=A2?= =?UTF-8?q?=E6=95=B0=E3=81=AE=E5=BC=95=E6=95=B0=E3=81=A7True/False?= =?UTF-8?q?=E3=81=AE=E5=80=A4=E3=82=92=E5=8F=97=E3=81=91=E5=8F=96=E3=82=8C?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=9F?= =?UTF-8?q?=E3=81=AE=E3=81=A7=E3=80=81view.py=E3=81=8C=E6=8F=90=E4=BE=9B?= =?UTF-8?q?=E3=81=97=E3=81=A6=E3=81=84=E3=81=9FgetButtonStatus=E7=B3=BB?= =?UTF-8?q?=E9=96=A2=E6=95=B0=E3=82=82=E5=89=8A=E9=99=A4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 16 ++++----- view.py | 21 +++++++----- .../main_window/createMainWindowWidgets.py | 2 +- .../main_window/widgets/create_sidebar.py | 33 +++++-------------- vrct_gui/vrct_gui.py | 10 +++--- 5 files changed, 35 insertions(+), 47 deletions(-) diff --git a/main.py b/main.py index 03774d60..58e3fd49 100644 --- a/main.py +++ b/main.py @@ -169,16 +169,16 @@ def callbackSelectedTabNo3(): # command func -def callbackToggleTranslation(): - config.ENABLE_TRANSLATION = view.getTranslationButtonStatus() +def callbackToggleTranslation(is_turned_on): + config.ENABLE_TRANSLATION = is_turned_on if config.ENABLE_TRANSLATION is True: view.printToTextbox_enableTranslation() else: view.printToTextbox_disableTranslation() -def callbackToggleTranscriptionSend(): +def callbackToggleTranscriptionSend(is_turned_on): view.setMainWindowAllWidgetsStatusToDisabled() - config.ENABLE_TRANSCRIPTION_SEND = view.getTranscriptionSendButtonStatus() + config.ENABLE_TRANSCRIPTION_SEND = is_turned_on if config.ENABLE_TRANSCRIPTION_SEND is True: view.printToTextbox_enableTranscriptionSend() th_startTranscriptionSendMessage = Thread(target=startTranscriptionSendMessage) @@ -190,9 +190,9 @@ def callbackToggleTranscriptionSend(): th_stopTranscriptionSendMessage.daemon = True th_stopTranscriptionSendMessage.start() -def callbackToggleTranscriptionReceive(): +def callbackToggleTranscriptionReceive(is_turned_on): view.setMainWindowAllWidgetsStatusToDisabled() - config.ENABLE_TRANSCRIPTION_RECEIVE = view.getTranscriptionReceiveButtonStatus() + config.ENABLE_TRANSCRIPTION_RECEIVE = is_turned_on if config.ENABLE_TRANSCRIPTION_RECEIVE is True: view.printToTextbox_enableTranscriptionReceive() th_startTranscriptionReceiveMessage = Thread(target=startTranscriptionReceiveMessage) @@ -204,8 +204,8 @@ def callbackToggleTranscriptionReceive(): th_stopTranscriptionReceiveMessage.daemon = True th_stopTranscriptionReceiveMessage.start() -def callbackToggleForeground(): - config.ENABLE_FOREGROUND = view.getForegroundButtonStatus() +def callbackToggleForeground(is_turned_on): + config.ENABLE_FOREGROUND = is_turned_on if config.ENABLE_FOREGROUND is True: view.printToTextbox_enableForeground() view.foregroundOn() diff --git a/view.py b/view.py index 248a8f3b..1c0c7abc 100644 --- a/view.py +++ b/view.py @@ -37,6 +37,18 @@ class View(): ) self.view_variable = SimpleNamespace( + + # Main Window + CALLBACK_TOGGLE_TRANSLATION=None, + CALLBACK_TOGGLE_TRANSCRIPTION_SEND=None, + CALLBACK_TOGGLE_TRANSCRIPTION_RECEIVE=None, + CALLBACK_TOGGLE_FOREGROUND=None, + # CALLBACK_SELECTED_TAB_NO_1=None, + # CALLBACK_SELECTED_TAB_NO_2=None, + # CALLBACK_SELECTED_TAB_NO_3=None, + + + # Config Window # Appearance Tab VAR_LABEL_TRANSPARENCY=StringVar(value="Transparency"), @@ -310,15 +322,6 @@ class View(): - def getTranslationButtonStatus(self): - return vrct_gui.translation_switch_box.get() - def getTranscriptionSendButtonStatus(self): - return vrct_gui.transcription_send_switch_box.get() - def getTranscriptionReceiveButtonStatus(self): - return vrct_gui.transcription_receive_switch_box.get() - def getForegroundButtonStatus(self): - return vrct_gui.foreground_switch_box.get() - def printToTextbox_enableTranslation(self): self._printToTextbox_Info("翻訳機能をONにしました") diff --git a/vrct_gui/main_window/createMainWindowWidgets.py b/vrct_gui/main_window/createMainWindowWidgets.py index 2949a7e7..980a15be 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, view_variable): +def createMainWindowWidgets(vrct_gui, settings): vrct_gui.protocol("WM_DELETE_WINDOW", vrct_gui.quitVRCT) # self.IS_DEVELOPER_MODE = False diff --git a/vrct_gui/main_window/widgets/create_sidebar.py b/vrct_gui/main_window/widgets/create_sidebar.py index 86e6b75f..9396d336 100644 --- a/vrct_gui/main_window/widgets/create_sidebar.py +++ b/vrct_gui/main_window/widgets/create_sidebar.py @@ -2,48 +2,33 @@ from customtkinter import CTkOptionMenu, CTkFont, CTkFrame, CTkLabel, CTkSwitch, from ...ui_utils import getImageFileFromUiUtils, openImageKeepAspectRatio, retag, getLatestHeight, bindEnterAndLeaveColor, bindButtonPressColor, bindEnterAndLeaveFunction, bindButtonReleaseFunction, bindButtonPressAndReleaseFunction, bindButtonFunctionAndColor, switchActiveTabAndPassiveTab, switchTabsColor -from time import sleep +from utils import callFunctionIfCallable def createSidebar(settings, main_window): - from vrct_gui import vrct_gui - changeMainWindowWidgetsStatus = vrct_gui.changeMainWindowWidgetsStatus - - - - def toggleSidebarFeatureSelectedMarkIfTurnedOn(is_turned_on, mark): mark.place(relx=0.85) if is_turned_on else mark.place(relx=-1) def toggleTranslationFeature(): - if callable(main_window.CALLBACK_TOGGLE_TRANSLATION) is True: - main_window.CALLBACK_TOGGLE_TRANSLATION() - is_turned_on = getattr(main_window, "translation_switch_box").get() - print(is_turned_on) + is_turned_on = main_window.translation_switch_box.get() + callFunctionIfCallable(main_window.CALLBACK_TOGGLE_TRANSLATION, is_turned_on) toggleSidebarFeatureSelectedMarkIfTurnedOn(is_turned_on, main_window.translation_selected_mark) def toggleTranscriptionSendFeature(): - if callable(main_window.CALLBACK_TOGGLE_TRANSCRIPTION_SEND) is True: - main_window.CALLBACK_TOGGLE_TRANSCRIPTION_SEND() - is_turned_on = getattr(main_window, "transcription_send_switch_box").get() - print(is_turned_on) + is_turned_on = main_window.transcription_send_switch_box.get() + callFunctionIfCallable(main_window.CALLBACK_TOGGLE_TRANSCRIPTION_SEND, is_turned_on) toggleSidebarFeatureSelectedMarkIfTurnedOn(is_turned_on, main_window.transcription_send_selected_mark) def toggleTranscriptionReceiveFeature(): - if callable(main_window.CALLBACK_TOGGLE_TRANSCRIPTION_RECEIVE) is True: - main_window.CALLBACK_TOGGLE_TRANSCRIPTION_RECEIVE() - is_turned_on = getattr(main_window, "transcription_receive_switch_box").get() - print(is_turned_on) + is_turned_on = main_window.transcription_receive_switch_box.get() + callFunctionIfCallable(main_window.CALLBACK_TOGGLE_TRANSCRIPTION_RECEIVE, is_turned_on) toggleSidebarFeatureSelectedMarkIfTurnedOn(is_turned_on, main_window.transcription_receive_selected_mark) - def toggleForegroundFeature(): - if callable(main_window.CALLBACK_TOGGLE_FOREGROUND) is True: - main_window.CALLBACK_TOGGLE_FOREGROUND() - is_turned_on = getattr(main_window, "foreground_switch_box").get() - print(is_turned_on) + is_turned_on = main_window.foreground_switch_box.get() + callFunctionIfCallable(main_window.CALLBACK_TOGGLE_FOREGROUND, is_turned_on) toggleSidebarFeatureSelectedMarkIfTurnedOn(is_turned_on, main_window.foreground_selected_mark) diff --git a/vrct_gui/vrct_gui.py b/vrct_gui/vrct_gui.py index 836ca7c5..5874b318 100644 --- a/vrct_gui/vrct_gui.py +++ b/vrct_gui/vrct_gui.py @@ -20,10 +20,10 @@ class VRCT_GUI(CTk): self.YOUR_LANGUAGE = "Japanese\n(Japan)" self.TARGET_LANGUAGE = "English\n(United States)" - self.CALLBACK_TOGGLE_TRANSLATION = None - self.CALLBACK_TOGGLE_TRANSCRIPTION_SEND = None - self.CALLBACK_TOGGLE_TRANSCRIPTION_RECEIVE = None - self.CALLBACK_TOGGLE_FOREGROUND = None + # self.CALLBACK_TOGGLE_TRANSLATION = None + # self.CALLBACK_TOGGLE_TRANSCRIPTION_SEND = None + # self.CALLBACK_TOGGLE_TRANSCRIPTION_RECEIVE = None + # self.CALLBACK_TOGGLE_FOREGROUND = None self.CALLBACK_SELECTED_TAB_NO_1 = None self.CALLBACK_SELECTED_TAB_NO_2 = None self.CALLBACK_SELECTED_TAB_NO_3 = None @@ -33,7 +33,7 @@ class VRCT_GUI(CTk): self.settings = settings self.view_variable = view_variable - createMainWindowWidgets(vrct_gui=self, settings=self.settings.main, view_variable=self.view_variable) + createMainWindowWidgets(vrct_gui=self, settings=self.settings.main) self.config_window = ConfigWindow(vrct_gui=self, settings=self.settings.config_window, view_variable=self.view_variable) # self.information_window = ToplevelWindowInformation(self) From fa82961eb33f9f90f55ce64ef87b82f298121a0a Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Sat, 2 Sep 2023 04:19:35 +0900 Subject: [PATCH 5/6] =?UTF-8?q?Main=20Window:=20Language=20Preset=20Tab=20?= =?UTF-8?q?Callback=E9=96=A2=E6=95=B0=E7=B3=BB=E3=80=82=E5=A4=89=E6=95=B0?= =?UTF-8?q?=E3=82=92view.py=E3=81=B8=E7=A7=BB=E5=8B=95=E3=80=82=20Callback?= =?UTF-8?q?=E6=99=82=E3=81=AB=E5=80=A4=E3=82=92=E5=8F=97=E3=81=91=E5=8F=96?= =?UTF-8?q?=E3=82=8C=E3=82=8B=E3=81=AE=E3=81=A7=E3=80=81tab=E7=95=AA?= =?UTF-8?q?=E5=8F=B7=E3=82=92=E3=82=82=E3=82=89=E3=81=A3=E3=81=A6=E4=B8=80?= =?UTF-8?q?=E3=81=A4=E3=81=AE=E9=96=A2=E6=95=B0=E3=81=A7=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 39 ++----------------- view.py | 9 ++--- .../main_window/widgets/create_sidebar.py | 19 ++------- vrct_gui/vrct_gui.py | 8 ---- 4 files changed, 9 insertions(+), 66 deletions(-) diff --git a/main.py b/main.py index 58e3fd49..6fa4987e 100644 --- a/main.py +++ b/main.py @@ -122,8 +122,8 @@ def setTargetLanguageAndCountry(select): config.TARGET_COUNTRY = country config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE) -def callbackSelectedTabNo1(): - config.SELECTED_TAB_NO = "1" +def callbackSelectedLanguagePresetTab(selected_tab_no): + config.SELECTED_TAB_NO = selected_tab_no view.updateGuiVariableByPresetTabNo(config.SELECTED_TAB_NO) languages = config.SELECTED_TAB_YOUR_LANGUAGES select = languages[config.SELECTED_TAB_NO] @@ -137,37 +137,6 @@ def callbackSelectedTabNo1(): config.TARGET_COUNTRY = country config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE) -def callbackSelectedTabNo2(): - config.SELECTED_TAB_NO = "2" - view.updateGuiVariableByPresetTabNo(config.SELECTED_TAB_NO) - languages = config.SELECTED_TAB_YOUR_LANGUAGES - select = languages[config.SELECTED_TAB_NO] - language, country = model.getLanguageAndCountry(select) - config.SOURCE_LANGUAGE = language - config.SOURCE_COUNTRY = country - languages = config.SELECTED_TAB_TARGET_LANGUAGES - select = languages[config.SELECTED_TAB_NO] - language, country = model.getLanguageAndCountry(select) - config.TARGET_LANGUAGE = language - config.TARGET_COUNTRY = country - config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE) - -def callbackSelectedTabNo3(): - config.SELECTED_TAB_NO = "3" - view.updateGuiVariableByPresetTabNo(config.SELECTED_TAB_NO) - languages = config.SELECTED_TAB_YOUR_LANGUAGES - select = languages[config.SELECTED_TAB_NO] - language, country = model.getLanguageAndCountry(select) - config.SOURCE_LANGUAGE = language - config.SOURCE_COUNTRY = country - languages = config.SELECTED_TAB_TARGET_LANGUAGES - select = languages[config.SELECTED_TAB_NO] - language, country = model.getLanguageAndCountry(select) - config.TARGET_LANGUAGE = language - config.TARGET_COUNTRY = country - config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE) - - # command func def callbackToggleTranslation(is_turned_on): config.ENABLE_TRANSLATION = is_turned_on @@ -404,9 +373,7 @@ view.register( "callback_target_language": setTargetLanguageAndCountry, "values": model.getListLanguageAndCountry(), - "callback_selected_tab_no_1": callbackSelectedTabNo1, - "callback_selected_tab_no_2": callbackSelectedTabNo2, - "callback_selected_tab_no_3": callbackSelectedTabNo3, + "callback_selected_language_preset_tab": callbackSelectedLanguagePresetTab, }, entry_message_box_commands={ diff --git a/view.py b/view.py index 1c0c7abc..0f425c36 100644 --- a/view.py +++ b/view.py @@ -43,9 +43,8 @@ class View(): CALLBACK_TOGGLE_TRANSCRIPTION_SEND=None, CALLBACK_TOGGLE_TRANSCRIPTION_RECEIVE=None, CALLBACK_TOGGLE_FOREGROUND=None, - # CALLBACK_SELECTED_TAB_NO_1=None, - # CALLBACK_SELECTED_TAB_NO_2=None, - # CALLBACK_SELECTED_TAB_NO_3=None, + + CALLBACK_SELECTED_LANGUAGE_PRESET_TAB=None, @@ -215,9 +214,7 @@ class View(): vrct_gui.sqls__optionmenu_target_language.configure(command=language_presets["callback_target_language"]) vrct_gui.sqls__optionmenu_target_language.configure(variable=StringVar(value=config.SELECTED_TAB_TARGET_LANGUAGES[config.SELECTED_TAB_NO])) - vrct_gui.CALLBACK_SELECTED_TAB_NO_1 = language_presets["callback_selected_tab_no_1"] - vrct_gui.CALLBACK_SELECTED_TAB_NO_2 = language_presets["callback_selected_tab_no_2"] - vrct_gui.CALLBACK_SELECTED_TAB_NO_3 = language_presets["callback_selected_tab_no_3"] + vrct_gui.CALLBACK_SELECTED_LANGUAGE_PRESET_TAB = language_presets["callback_selected_language_preset_tab"] vrct_gui.setDefaultActiveLanguagePresetTab(tab_no=config.SELECTED_TAB_NO) diff --git a/vrct_gui/main_window/widgets/create_sidebar.py b/vrct_gui/main_window/widgets/create_sidebar.py index 9396d336..bbf3fb8d 100644 --- a/vrct_gui/main_window/widgets/create_sidebar.py +++ b/vrct_gui/main_window/widgets/create_sidebar.py @@ -99,34 +99,21 @@ def createSidebar(settings, main_window): - - - - def switchToPreset1(e): print("1") - if callable(main_window.CALLBACK_SELECTED_TAB_NO_1) is True: - main_window.CALLBACK_SELECTED_TAB_NO_1() - # main_window.YOUR_LANGUAGE = "Japanese\n(Japan)" - # main_window.TARGET_LANGUAGE = "English\n(United States)" + callFunctionIfCallable(main_window.CALLBACK_SELECTED_LANGUAGE_PRESET_TAB, "1") target_active_widget = getattr(main_window, "sqls__presets_button_1") switchPresetTabFunction(target_active_widget) def switchToPreset2(e): print("2") - if callable(main_window.CALLBACK_SELECTED_TAB_NO_2) is True: - main_window.CALLBACK_SELECTED_TAB_NO_2() - # main_window.YOUR_LANGUAGE = "English\n(United States)" - # main_window.TARGET_LANGUAGE = "Japanese\n(Japan)" + callFunctionIfCallable(main_window.CALLBACK_SELECTED_LANGUAGE_PRESET_TAB, "2") target_active_widget = getattr(main_window, "sqls__presets_button_2") switchPresetTabFunction(target_active_widget) def switchToPreset3(e): print("3") - if callable(main_window.CALLBACK_SELECTED_TAB_NO_3) is True: - main_window.CALLBACK_SELECTED_TAB_NO_3() - # main_window.YOUR_LANGUAGE = "Japanese\n(Japan)" - # main_window.TARGET_LANGUAGE = "Chinese, Cantonese\n(Traditional Hong Kong)" + callFunctionIfCallable(main_window.CALLBACK_SELECTED_LANGUAGE_PRESET_TAB, "3") target_active_widget = getattr(main_window, "sqls__presets_button_3") switchPresetTabFunction(target_active_widget) diff --git a/vrct_gui/vrct_gui.py b/vrct_gui/vrct_gui.py index 5874b318..f0871ace 100644 --- a/vrct_gui/vrct_gui.py +++ b/vrct_gui/vrct_gui.py @@ -20,14 +20,6 @@ class VRCT_GUI(CTk): self.YOUR_LANGUAGE = "Japanese\n(Japan)" self.TARGET_LANGUAGE = "English\n(United States)" - # self.CALLBACK_TOGGLE_TRANSLATION = None - # self.CALLBACK_TOGGLE_TRANSCRIPTION_SEND = None - # self.CALLBACK_TOGGLE_TRANSCRIPTION_RECEIVE = None - # self.CALLBACK_TOGGLE_FOREGROUND = None - self.CALLBACK_SELECTED_TAB_NO_1 = None - self.CALLBACK_SELECTED_TAB_NO_2 = None - self.CALLBACK_SELECTED_TAB_NO_3 = None - def createGUI(self, settings, view_variable): self.settings = settings From ce65a36b8dc52b706bcb9c7b126799e8c5e97b74 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Sat, 2 Sep 2023 05:27:52 +0900 Subject: [PATCH 6/6] =?UTF-8?q?Main=20Window:=20Language=20Setting?= =?UTF-8?q?=E3=81=AE=E5=A4=89=E6=95=B0YOUR=5FLANGUAGE=E3=81=A8TARGET=5FLAN?= =?UTF-8?q?GUAGE=E3=82=92view.py=E3=81=AB=E7=A7=BB=E5=8B=95=E3=80=82=20tab?= =?UTF-8?q?=E5=88=87=E3=82=8A=E6=9B=BF=E3=82=8F=E3=82=8A=E6=99=82=E3=81=AB?= =?UTF-8?q?=E3=80=81UI=E5=81=B4=E3=81=A7variable=E3=82=92=E3=81=AA?= =?UTF-8?q?=E3=81=9C=E3=81=8B=E6=96=B0=E3=81=9F=E3=81=AB=E3=82=BB=E3=83=83?= =?UTF-8?q?=E3=83=88=E3=81=97=E3=81=A6=E3=81=84=E3=81=9F=E3=81=AE=E3=81=A7?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3(set=E9=96=A2=E6=95=B0=E3=82=92=E4=BD=BF?= =?UTF-8?q?=E3=81=A3=E3=81=A6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view.py | 13 ++++++++----- vrct_gui/main_window/createMainWindowWidgets.py | 9 --------- vrct_gui/main_window/widgets/create_sidebar.py | 8 ++++---- vrct_gui/vrct_gui.py | 4 ---- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/view.py b/view.py index 0f425c36..5c113939 100644 --- a/view.py +++ b/view.py @@ -37,14 +37,17 @@ class View(): ) self.view_variable = SimpleNamespace( - # Main Window + # Sidebar Features CALLBACK_TOGGLE_TRANSLATION=None, CALLBACK_TOGGLE_TRANSCRIPTION_SEND=None, CALLBACK_TOGGLE_TRANSCRIPTION_RECEIVE=None, CALLBACK_TOGGLE_FOREGROUND=None, + # Language Settings CALLBACK_SELECTED_LANGUAGE_PRESET_TAB=None, + VAR_YOUR_LANGUAGE = StringVar(value="Japanese\n(Japan)"), + VAR_TARGET_LANGUAGE = StringVar(value="English\n(United States)"), @@ -241,6 +244,8 @@ class View(): 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) @@ -314,10 +319,8 @@ class View(): def updateGuiVariableByPresetTabNo(self, tab_no:str): - vrct_gui.YOUR_LANGUAGE = config.SELECTED_TAB_YOUR_LANGUAGES[tab_no] - vrct_gui.TARGET_LANGUAGE = config.SELECTED_TAB_TARGET_LANGUAGES[tab_no] - - + self.view_variable.VAR_YOUR_LANGUAGE.set(config.SELECTED_TAB_YOUR_LANGUAGES[tab_no]) + self.view_variable.VAR_TARGET_LANGUAGE.set(config.SELECTED_TAB_TARGET_LANGUAGES[tab_no]) def printToTextbox_enableTranslation(self): diff --git a/vrct_gui/main_window/createMainWindowWidgets.py b/vrct_gui/main_window/createMainWindowWidgets.py index 980a15be..536aba6c 100644 --- a/vrct_gui/main_window/createMainWindowWidgets.py +++ b/vrct_gui/main_window/createMainWindowWidgets.py @@ -8,14 +8,6 @@ from ..ui_utils import createButtonWithImage, getImagePath def createMainWindowWidgets(vrct_gui, settings): vrct_gui.protocol("WM_DELETE_WINDOW", vrct_gui.quitVRCT) - # self.IS_DEVELOPER_MODE = False - # self.IS_DEVELOPER_MODE = True - - - - - # self.YOUR_LANGUAGE = "Japanese\n(Japan)" - # self.TARGET_LANGUAGE = "English\n(United States)" vrct_gui.iconbitmap(getImagePath("app.ico")) vrct_gui.title("VRCT") @@ -27,7 +19,6 @@ def createMainWindowWidgets(vrct_gui, settings): vrct_gui.grid_columnconfigure(1, weight=1) vrct_gui.configure(fg_color="#ff7f50") - # return # Main Container diff --git a/vrct_gui/main_window/widgets/create_sidebar.py b/vrct_gui/main_window/widgets/create_sidebar.py index bbf3fb8d..d69632d5 100644 --- a/vrct_gui/main_window/widgets/create_sidebar.py +++ b/vrct_gui/main_window/widgets/create_sidebar.py @@ -93,8 +93,8 @@ def createSidebar(settings, main_window): switchActiveAndPassivePresetsTabsColor(target_active_widget) switchActiveTabAndPassiveTab(target_active_widget, main_window.current_active_preset_tab, main_window.current_active_preset_tab.passive_function, settings.ctm.SQLS__PRESETS_TAB_BG_HOVERED_COLOR, settings.ctm.SQLS__PRESETS_TAB_BG_CLICKED_COLOR, settings.ctm.SQLS__PRESETS_TAB_BG_PASSIVE_COLOR) - main_window.sqls__optionmenu_your_language.configure(variable=StringVar(value=main_window.YOUR_LANGUAGE)) - main_window.sqls__optionmenu_target_language.configure(variable=StringVar(value=main_window.TARGET_LANGUAGE)) + main_window.sqls__optionmenu_your_language.set(main_window.view_variable.VAR_YOUR_LANGUAGE.get()) + main_window.sqls__optionmenu_target_language.set(main_window.view_variable.VAR_TARGET_LANGUAGE.get()) main_window.current_active_preset_tab = target_active_widget @@ -499,7 +499,7 @@ def createSidebar(settings, main_window): optionmenu_attr_name="sqls__optionmenu_your_language", dropdown_menu_attr_name="sqls__dropdown_menu_your_language", dropdown_menu_values=["1""2","pppp\npppp"], - variable=StringVar(value=main_window.YOUR_LANGUAGE) + variable=main_window.view_variable.VAR_YOUR_LANGUAGE ) main_window.sqls__box_your_language.grid(row=2, column=0, padx=0, pady=(settings.uism.SQLS__BOX_TOP_PADY,0),sticky="ew") @@ -549,7 +549,7 @@ def createSidebar(settings, main_window): optionmenu_attr_name="sqls__optionmenu_target_language", dropdown_menu_attr_name="sqls__dropdown_menu_target_language", dropdown_menu_values=["1""2","pppp\npppp2"], - variable=StringVar(value=main_window.TARGET_LANGUAGE) + variable=main_window.view_variable.VAR_TARGET_LANGUAGE ) main_window.sqls__box_target_language.grid(row=4, column=0, padx=0, pady=(0,0),sticky="ew") diff --git a/vrct_gui/vrct_gui.py b/vrct_gui/vrct_gui.py index f0871ace..89e7804c 100644 --- a/vrct_gui/vrct_gui.py +++ b/vrct_gui/vrct_gui.py @@ -16,10 +16,6 @@ from .ui_utils import _setDefaultActiveTab class VRCT_GUI(CTk): def __init__(self): super().__init__() - # self.settings = SimpleNamespace() - self.YOUR_LANGUAGE = "Japanese\n(Japan)" - self.TARGET_LANGUAGE = "English\n(United States)" - def createGUI(self, settings, view_variable): self.settings = settings