From 8a91cffcf46d832ea7615bf11d3e04d3fad2d729 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Mon, 4 Sep 2023 23:43:22 +0900 Subject: [PATCH] =?UTF-8?q?[bugifx]=20Main=20Window:=20view=5Fvariable(vie?= =?UTF-8?q?w.py=E5=A4=89=E6=95=B0)=E3=81=AE=E5=8F=82=E7=85=A7=E3=81=AE?= =?UTF-8?q?=E4=BB=95=E6=96=B9=E3=81=8C=E3=81=8A=E3=81=8B=E3=81=97=E3=81=8F?= =?UTF-8?q?=E3=80=81=E6=84=8F=E5=9B=B3=E3=81=97=E3=81=9F=E5=80=A4=E3=81=AE?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E3=81=A8=E5=8F=82=E7=85=A7=E3=81=8C=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=81=A6=E3=81=84=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F?= =?UTF-8?q?=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vrct_gui/_changeMainWindowWidgetsStatus.py | 10 +++++----- .../main_window/createMainWindowWidgets.py | 6 +++--- .../_create_sidebar/createSidebarFeatures.py | 18 +++++++++--------- .../createSidebarLanguagesSettings.py | 16 ++++++++-------- .../widgets/create_minimize_sidebar_button.py | 8 ++++---- vrct_gui/main_window/widgets/create_sidebar.py | 8 ++++---- vrct_gui/vrct_gui.py | 11 ++++++----- 7 files changed, 39 insertions(+), 38 deletions(-) diff --git a/vrct_gui/_changeMainWindowWidgetsStatus.py b/vrct_gui/_changeMainWindowWidgetsStatus.py index af8b51d8..4fed6db0 100644 --- a/vrct_gui/_changeMainWindowWidgetsStatus.py +++ b/vrct_gui/_changeMainWindowWidgetsStatus.py @@ -3,7 +3,7 @@ from customtkinter import CTkImage from .ui_utils import getImageFileFromUiUtils -def _changeMainWindowWidgetsStatus(vrct_gui, settings, status, target_names): +def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, target_names): COMPACT_MODE_ICON_SIZE_TUPLES = (settings.COMPACT_MODE_ICON_SIZE, settings.COMPACT_MODE_ICON_SIZE) if target_names == "All": @@ -85,7 +85,7 @@ def _changeMainWindowWidgetsStatus(vrct_gui, settings, status, target_names): vrct_gui.sls__container_title.configure(text_color=settings.ctm.SF__TEXT_DISABLED_COLOR) vrct_gui.sls__title_text_your_language.configure(text_color=settings.ctm.SF__TEXT_DISABLED_COLOR) vrct_gui.sls__title_text_target_language.configure(text_color=settings.ctm.SF__TEXT_DISABLED_COLOR) - if vrct_gui.view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE is False: + if view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE is False: vrct_gui.current_active_preset_tab.children["!ctklabel"].configure(text_color=settings.ctm.SLS__PRESETS_TAB_ACTIVE_TEXT_COLOR_PASSIVE) vrct_gui.sls__optionmenu_your_language.configure(state="disabled") vrct_gui.sls__optionmenu_target_language.configure(state="disabled") @@ -94,7 +94,7 @@ def _changeMainWindowWidgetsStatus(vrct_gui, settings, status, target_names): vrct_gui.sls__container_title.configure(text_color=settings.ctm.LABELS_TEXT_COLOR) vrct_gui.sls__title_text_your_language.configure(text_color=settings.ctm.LABELS_TEXT_COLOR) vrct_gui.sls__title_text_target_language.configure(text_color=settings.ctm.LABELS_TEXT_COLOR) - if vrct_gui.view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE is False: + if view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE is False: vrct_gui.current_active_preset_tab.children["!ctklabel"].configure(text_color=settings.ctm.SLS__PRESETS_TAB_ACTIVE_TEXT_COLOR) vrct_gui.current_active_preset_tab.children["!ctklabel"].configure(text_color=settings.ctm.SLS__PRESETS_TAB_ACTIVE_TEXT_COLOR) vrct_gui.sls__optionmenu_your_language.configure(state="normal") @@ -120,7 +120,7 @@ def _changeMainWindowWidgetsStatus(vrct_gui, settings, status, target_names): vrct_gui.minimize_sidebar_button_container.configure(cursor="") - if vrct_gui.view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE is True: + if view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE is True: image_file = CTkImage(getImageFileFromUiUtils(settings.image_filename.ARROW_LEFT_DISABLED).rotate(180), size=LOGO_SIZE) else: image_file = CTkImage(getImageFileFromUiUtils(settings.image_filename.ARROW_LEFT_DISABLED), size=LOGO_SIZE) @@ -128,7 +128,7 @@ def _changeMainWindowWidgetsStatus(vrct_gui, settings, status, target_names): elif status == "normal": vrct_gui.minimize_sidebar_button_container.configure(cursor="hand2") - if vrct_gui.view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE is True: + if view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE is True: image_file = CTkImage(getImageFileFromUiUtils(settings.image_filename.ARROW_LEFT).rotate(180), size=LOGO_SIZE) else: image_file = CTkImage(getImageFileFromUiUtils(settings.image_filename.ARROW_LEFT), size=LOGO_SIZE) diff --git a/vrct_gui/main_window/createMainWindowWidgets.py b/vrct_gui/main_window/createMainWindowWidgets.py index 08687539..9a33ef0c 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) @@ -56,9 +56,9 @@ def createMainWindowWidgets(vrct_gui, settings): ) vrct_gui.help_and_info_button_container.grid(row=0, column=3, padx=settings.uism.HELP_AND_INFO_BUTTON_PADX, pady=settings.uism.HELP_AND_INFO_BUTTON_PADY, sticky="e") - createSidebar(settings, vrct_gui) + createSidebar(settings, vrct_gui, view_variable) - createMinimizeSidebarButton(settings, vrct_gui) + createMinimizeSidebarButton(settings, vrct_gui, view_variable) createTextbox(settings, vrct_gui) diff --git a/vrct_gui/main_window/widgets/_create_sidebar/createSidebarFeatures.py b/vrct_gui/main_window/widgets/_create_sidebar/createSidebarFeatures.py index 7547746e..aec073a7 100644 --- a/vrct_gui/main_window/widgets/_create_sidebar/createSidebarFeatures.py +++ b/vrct_gui/main_window/widgets/_create_sidebar/createSidebarFeatures.py @@ -5,7 +5,7 @@ from ....ui_utils import getImageFileFromUiUtils, openImageKeepAspectRatio, reta from utils import callFunctionIfCallable -def createSidebarFeatures(settings, main_window): +def createSidebarFeatures(settings, main_window, view_variable): def toggleSidebarFeatureSelectedMarkIfTurnedOn(is_turned_on, mark): mark.place(relx=0.85) if is_turned_on else mark.place(relx=-1) @@ -13,22 +13,22 @@ def createSidebarFeatures(settings, main_window): def toggleTranslationFeature(): is_turned_on = main_window.translation_switch_box.get() - callFunctionIfCallable(main_window.CALLBACK_TOGGLE_TRANSLATION, is_turned_on) + callFunctionIfCallable(view_variable.CALLBACK_TOGGLE_TRANSLATION, is_turned_on) toggleSidebarFeatureSelectedMarkIfTurnedOn(is_turned_on, main_window.translation_selected_mark) def toggleTranscriptionSendFeature(): is_turned_on = main_window.transcription_send_switch_box.get() - callFunctionIfCallable(main_window.CALLBACK_TOGGLE_TRANSCRIPTION_SEND, is_turned_on) + callFunctionIfCallable(view_variable.CALLBACK_TOGGLE_TRANSCRIPTION_SEND, is_turned_on) toggleSidebarFeatureSelectedMarkIfTurnedOn(is_turned_on, main_window.transcription_send_selected_mark) def toggleTranscriptionReceiveFeature(): is_turned_on = main_window.transcription_receive_switch_box.get() - callFunctionIfCallable(main_window.CALLBACK_TOGGLE_TRANSCRIPTION_RECEIVE, is_turned_on) + callFunctionIfCallable(view_variable.CALLBACK_TOGGLE_TRANSCRIPTION_RECEIVE, is_turned_on) toggleSidebarFeatureSelectedMarkIfTurnedOn(is_turned_on, main_window.transcription_receive_selected_mark) def toggleForegroundFeature(): is_turned_on = main_window.foreground_switch_box.get() - callFunctionIfCallable(main_window.CALLBACK_TOGGLE_FOREGROUND, is_turned_on) + callFunctionIfCallable(view_variable.CALLBACK_TOGGLE_FOREGROUND, is_turned_on) toggleSidebarFeatureSelectedMarkIfTurnedOn(is_turned_on, main_window.foreground_selected_mark) @@ -118,7 +118,7 @@ def createSidebarFeatures(settings, main_window): "compact_mode_icon_attr_name": "translation_compact_mode_icon", "compact_mode_frame_attr_name": "compact_mode_translation_frame", "selected_mark_attr_name": "translation_selected_mark", - "var_label_text": main_window.view_variable.VAR_LABEL_TRANSLATION, + "var_label_text": view_variable.VAR_LABEL_TRANSLATION, "icon_file_name": settings.image_filename.TRANSLATION_ICON, }, { @@ -130,7 +130,7 @@ def createSidebarFeatures(settings, main_window): "compact_mode_icon_attr_name": "transcription_send_compact_mode_icon", "compact_mode_frame_attr_name": "compact_mode_transcription_send_frame", "selected_mark_attr_name": "transcription_send_selected_mark", - "var_label_text": main_window.view_variable.VAR_LABEL_TRANSCRIPTION_SEND, + "var_label_text": view_variable.VAR_LABEL_TRANSCRIPTION_SEND, "icon_file_name": settings.image_filename.MIC_ICON, }, { @@ -142,7 +142,7 @@ def createSidebarFeatures(settings, main_window): "compact_mode_icon_attr_name": "transcription_receive_compact_mode_icon", "compact_mode_frame_attr_name": "compact_mode_transcription_receive_frame", "selected_mark_attr_name": "transcription_receive_selected_mark", - "var_label_text": main_window.view_variable.VAR_LABEL_TRANSCRIPTION_RECEIVE, + "var_label_text": view_variable.VAR_LABEL_TRANSCRIPTION_RECEIVE, "icon_file_name": settings.image_filename.HEADPHONES_ICON, }, { @@ -154,7 +154,7 @@ def createSidebarFeatures(settings, main_window): "compact_mode_icon_attr_name": "foreground_compact_mode_icon", "compact_mode_frame_attr_name": "compact_mode_foreground_frame", "selected_mark_attr_name": "foreground_selected_mark", - "var_label_text": main_window.view_variable.VAR_LABEL_FOREGROUND, + "var_label_text": view_variable.VAR_LABEL_FOREGROUND, "icon_file_name": settings.image_filename.FOREGROUND_ICON, }, ] diff --git a/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py b/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py index a84e8384..bdd57585 100644 --- a/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py +++ b/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py @@ -5,7 +5,7 @@ from ....ui_utils import getImageFileFromUiUtils, bindEnterAndLeaveColor, bindBu from utils import callFunctionIfCallable -def createSidebarLanguagesSettings(settings, main_window): +def createSidebarLanguagesSettings(settings, main_window, view_variable): def switchActiveAndPassivePresetsTabsColor(target_active_widget): @@ -28,27 +28,27 @@ def createSidebarLanguagesSettings(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.SLS__PRESETS_TAB_BG_HOVERED_COLOR, settings.ctm.SLS__PRESETS_TAB_BG_CLICKED_COLOR, settings.ctm.SLS__PRESETS_TAB_BG_PASSIVE_COLOR) - main_window.sls__optionmenu_your_language.set(main_window.view_variable.VAR_YOUR_LANGUAGE.get()) - main_window.sls__optionmenu_target_language.set(main_window.view_variable.VAR_TARGET_LANGUAGE.get()) + main_window.sls__optionmenu_your_language.set(view_variable.VAR_YOUR_LANGUAGE.get()) + main_window.sls__optionmenu_target_language.set(view_variable.VAR_TARGET_LANGUAGE.get()) main_window.current_active_preset_tab = target_active_widget def switchToPreset1(e): print("1") - callFunctionIfCallable(main_window.CALLBACK_SELECTED_LANGUAGE_PRESET_TAB, "1") + callFunctionIfCallable(view_variable.CALLBACK_SELECTED_LANGUAGE_PRESET_TAB, "1") target_active_widget = getattr(main_window, "sls__presets_button_1") switchPresetTabFunction(target_active_widget) def switchToPreset2(e): print("2") - callFunctionIfCallable(main_window.CALLBACK_SELECTED_LANGUAGE_PRESET_TAB, "2") + callFunctionIfCallable(view_variable.CALLBACK_SELECTED_LANGUAGE_PRESET_TAB, "2") target_active_widget = getattr(main_window, "sls__presets_button_2") switchPresetTabFunction(target_active_widget) def switchToPreset3(e): print("3") - callFunctionIfCallable(main_window.CALLBACK_SELECTED_LANGUAGE_PRESET_TAB, "3") + callFunctionIfCallable(view_variable.CALLBACK_SELECTED_LANGUAGE_PRESET_TAB, "3") target_active_widget = getattr(main_window, "sls__presets_button_3") switchPresetTabFunction(target_active_widget) @@ -219,7 +219,7 @@ def createSidebarLanguagesSettings(settings, main_window): optionmenu_attr_name="sls__optionmenu_your_language", dropdown_menu_attr_name="sls__dropdown_menu_your_language", dropdown_menu_values=["1""2","pppp\npppp"], - variable=main_window.view_variable.VAR_YOUR_LANGUAGE + variable=view_variable.VAR_YOUR_LANGUAGE ) main_window.sls__box_your_language.grid(row=2, column=0, padx=0, pady=(settings.uism.SLS__BOX_TOP_PADY,0),sticky="ew") @@ -269,7 +269,7 @@ def createSidebarLanguagesSettings(settings, main_window): optionmenu_attr_name="sls__optionmenu_target_language", dropdown_menu_attr_name="sls__dropdown_menu_target_language", dropdown_menu_values=["1""2","pppp\npppp2"], - variable=main_window.view_variable.VAR_TARGET_LANGUAGE + variable=view_variable.VAR_TARGET_LANGUAGE ) main_window.sls__box_target_language.grid(row=4, column=0, padx=0, pady=(0,0),sticky="ew") diff --git a/vrct_gui/main_window/widgets/create_minimize_sidebar_button.py b/vrct_gui/main_window/widgets/create_minimize_sidebar_button.py index 6cfd0ce0..da06788b 100644 --- a/vrct_gui/main_window/widgets/create_minimize_sidebar_button.py +++ b/vrct_gui/main_window/widgets/create_minimize_sidebar_button.py @@ -5,13 +5,13 @@ from ...ui_utils import getImageFileFromUiUtils, bindEnterAndLeaveColor, bindBut from utils import callFunctionIfCallable -def createMinimizeSidebarButton(settings, main_window): +def createMinimizeSidebarButton(settings, main_window, view_variable): def enableCompactMode(e): - callFunctionIfCallable(main_window.view_variable.CALLBACK_TOGGLE_MAIN_WINDOW_SIDEBAR_COMPACT_MODE, True) + callFunctionIfCallable(view_variable.CALLBACK_TOGGLE_MAIN_WINDOW_SIDEBAR_COMPACT_MODE, True) def disableCompactMode(e): - callFunctionIfCallable(main_window.view_variable.CALLBACK_TOGGLE_MAIN_WINDOW_SIDEBAR_COMPACT_MODE, False) + callFunctionIfCallable(view_variable.CALLBACK_TOGGLE_MAIN_WINDOW_SIDEBAR_COMPACT_MODE, False) @@ -28,7 +28,7 @@ def createMinimizeSidebarButton(settings, main_window): ) - if main_window.view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE is True: + if view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE is True: image_file = CTkImage(getImageFileFromUiUtils(settings.image_filename.ARROW_LEFT).rotate(180),size=(settings.uism.MINIMIZE_SIDEBAR_BUTTON_ICON_SIZE_X,settings.uism.MINIMIZE_SIDEBAR_BUTTON_ICON_SIZE_Y)) bindButtonReleaseFunction([main_window.minimize_sidebar_button_container, main_window.minimize_sidebar_button], disableCompactMode) diff --git a/vrct_gui/main_window/widgets/create_sidebar.py b/vrct_gui/main_window/widgets/create_sidebar.py index 967d3268..12323aad 100644 --- a/vrct_gui/main_window/widgets/create_sidebar.py +++ b/vrct_gui/main_window/widgets/create_sidebar.py @@ -2,7 +2,7 @@ from customtkinter import CTkFrame from ._create_sidebar import createSidebarFeatures, createSidebarLanguagesSettings -def createSidebar(settings, main_window): +def createSidebar(settings, main_window, view_variable): # Side Bar Container main_window.grid_rowconfigure(0, weight=1) @@ -14,14 +14,14 @@ def createSidebar(settings, main_window): main_window.sidebar_compact_mode_bg_container.grid_columnconfigure(0, weight=0, minsize=settings.uism.COMPACT_MODE_SIDEBAR_WIDTH) - createSidebarFeatures(settings, main_window) - createSidebarLanguagesSettings(settings, main_window) + createSidebarFeatures(settings, main_window, view_variable) + createSidebarLanguagesSettings(settings, main_window, view_variable) main_window.sidebar_bg_container.grid(row=0, column=0, sticky="nsew") main_window.sidebar_compact_mode_bg_container.grid(row=0, column=0, sticky="nsew") - if main_window.view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE: + if view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE: main_window.sidebar_bg_container.grid_remove() else: main_window.sidebar_compact_mode_bg_container.grid_remove() \ No newline at end of file diff --git a/vrct_gui/vrct_gui.py b/vrct_gui/vrct_gui.py index b33d3728..8275f04a 100644 --- a/vrct_gui/vrct_gui.py +++ b/vrct_gui/vrct_gui.py @@ -21,10 +21,10 @@ class VRCT_GUI(CTk): def createGUI(self, settings, view_variable): self.settings = settings - self.view_variable = view_variable + 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, view_variable=self.view_variable) + 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): @@ -57,6 +57,7 @@ class VRCT_GUI(CTk): _changeMainWindowWidgetsStatus( vrct_gui=self, settings=self.settings.main, + view_variable=self._view_variable, status=status, target_names=target_names, ) @@ -80,9 +81,9 @@ class VRCT_GUI(CTk): def recreateMainWindowSidebar(self): self.minimize_sidebar_button_container.destroy() - createMinimizeSidebarButton(self.settings.main, self) + createMinimizeSidebarButton(self.settings.main, self, view_variable=self._view_variable) - if self.view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE: + if self._view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE: self.sidebar_bg_container.grid_remove() self.sidebar_compact_mode_bg_container.grid() else: