From 08d3f0473897c0f3997d55d508769b750c4724a3 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Thu, 31 Aug 2023 19:13:14 +0900 Subject: [PATCH] add UI and Feature: Config Window Compact Mode. --- config.py | 14 ++++++++++++++ main.py | 15 +++++++++++++++ view.py | 16 +++++++++++++++- vrct_gui/config_window/ConfigWindow.py | 8 ++++++++ .../_createSettingBoxCompactModeButton.py | 13 ++++++++++++- vrct_gui/vrct_gui.py | 8 ++++---- 6 files changed, 68 insertions(+), 6 deletions(-) diff --git a/config.py b/config.py index e6199231..a66921a4 100644 --- a/config.py +++ b/config.py @@ -442,6 +442,17 @@ class Config: self._SELECTED_TAB_TARGET_LANGUAGES = value saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) + # Config Window + @property + def IS_CONFIG_WINDOW_COMPACT_MODE(self): + return self._IS_CONFIG_WINDOW_COMPACT_MODE + + @IS_CONFIG_WINDOW_COMPACT_MODE.setter + def IS_CONFIG_WINDOW_COMPACT_MODE(self, value): + if type(value) is bool: + self._IS_CONFIG_WINDOW_COMPACT_MODE = value + saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) + def init_config(self): self._VERSION = "1.3.2" self._PATH_CONFIG = "./config.json" @@ -505,6 +516,9 @@ class Config: "3":"English\n(United States)", } + # Config Window + self._IS_CONFIG_WINDOW_COMPACT_MODE = False + def load_config(self): if os_path.isfile(self.PATH_CONFIG) is not False: with open(self.PATH_CONFIG, 'r') as fp: diff --git a/main.py b/main.py index d1a39236..b6bf26b2 100644 --- a/main.py +++ b/main.py @@ -211,6 +211,16 @@ def callbackToggleForeground(): view.printToTextbox_disableForeground() view.foregroundOff() + +# Config Window +def callbackEnableConfigWindowCompactMode(): + config.IS_CONFIG_WINDOW_COMPACT_MODE = True + view.reloadConfigWindowSettingBoxContainer() + +def callbackDisableConfigWindowCompactMode(): + config.IS_CONFIG_WINDOW_COMPACT_MODE = False + view.reloadConfigWindowSettingBoxContainer() + # create GUI view.createGUI() @@ -257,6 +267,11 @@ view.initializer( # }, entry_message_box_bind_Return=messageBoxPressKeyEnter, entry_message_box_bind_Any_KeyPress=messageBoxPressKeyAny, + + config_window={ + "callback_disable_config_window_compact_mode": callbackEnableConfigWindowCompactMode, + "callback_enable_config_window_compact_mode": callbackDisableConfigWindowCompactMode, + }, ) if __name__ == "__main__": diff --git a/view.py b/view.py index 0f7c2590..905c936f 100644 --- a/view.py +++ b/view.py @@ -8,7 +8,7 @@ class View(): pass - def initializer(self, sidebar_features, language_presets, entry_message_box, entry_message_box_bind_Return, entry_message_box_bind_Any_KeyPress): + def initializer(self, sidebar_features, language_presets, entry_message_box, entry_message_box_bind_Return, entry_message_box_bind_Any_KeyPress, config_window): vrct_gui.CALLBACK_TOGGLE_TRANSLATION = sidebar_features["callback_toggle_translation"] vrct_gui.CALLBACK_TOGGLE_TRANSCRIPTION_SEND = sidebar_features["callback_toggle_transcription_send"] @@ -39,6 +39,14 @@ class View(): entry_message_box.bind("", self._foregroundOnForcefully) + vrct_gui.config_window.CALLBACK_ENABLE_CONFIG_WINDOW_COMPACT_MODE = config_window["callback_disable_config_window_compact_mode"] + vrct_gui.config_window.CALLBACK_DISABLE_CONFIG_WINDOW_COMPACT_MODE = config_window["callback_enable_config_window_compact_mode"] + + + # Config Window + vrct_gui.config_window.settings.IS_CONFIG_WINDOW_COMPACT_MODE = config.IS_CONFIG_WINDOW_COMPACT_MODE + + def setMainWindowAllWidgetsStatusToNormal(self): vrct_gui.changeMainWindowWidgetsStatus("normal", "All") @@ -148,4 +156,10 @@ class View(): def startMainLoop(self): vrct_gui.startMainLoop() + + # Config Window + def reloadConfigWindowSettingBoxContainer(self): + vrct_gui.config_window.settings.IS_CONFIG_WINDOW_COMPACT_MODE = config.IS_CONFIG_WINDOW_COMPACT_MODE + vrct_gui.config_window.reloadConfigWindowSettingBoxContainer() + view = View() \ No newline at end of file diff --git a/vrct_gui/config_window/ConfigWindow.py b/vrct_gui/config_window/ConfigWindow.py index 40f4c3bc..3143fc19 100644 --- a/vrct_gui/config_window/ConfigWindow.py +++ b/vrct_gui/config_window/ConfigWindow.py @@ -17,6 +17,7 @@ class ConfigWindow(CTkToplevel): self.configure(fg_color="#ff7f50") self.protocol("WM_DELETE_WINDOW", vrct_gui.closeConfigWindow) + self.settings = settings @@ -26,3 +27,10 @@ class ConfigWindow(CTkToplevel): createSideMenuAndSettingsBoxContainers(config_window=self, settings=settings) + + + + + def reloadConfigWindowSettingBoxContainer(self): + self.main_bg_container.destroy() + createSideMenuAndSettingsBoxContainers(config_window=self, settings=self.settings) \ No newline at end of file diff --git a/vrct_gui/config_window/widgets/createSettingBoxTopBar/_createSettingBoxCompactModeButton.py b/vrct_gui/config_window/widgets/createSettingBoxTopBar/_createSettingBoxCompactModeButton.py index ce98730a..0d9e21ed 100644 --- a/vrct_gui/config_window/widgets/createSettingBoxTopBar/_createSettingBoxCompactModeButton.py +++ b/vrct_gui/config_window/widgets/createSettingBoxTopBar/_createSettingBoxCompactModeButton.py @@ -2,6 +2,17 @@ from customtkinter import CTkFont, CTkFrame, CTkLabel, CTkSwitch def _createSettingBoxCompactModeButton(parent_widget, config_window, settings): + def switchConfigWindowCompactMode(): + print(config_window.setting_box_compact_mode_switch_box.get()) + if config_window.setting_box_compact_mode_switch_box.get() is True: + if callable(config_window.CALLBACK_ENABLE_CONFIG_WINDOW_COMPACT_MODE) is True: + config_window.CALLBACK_ENABLE_CONFIG_WINDOW_COMPACT_MODE() + else: + if callable(config_window.CALLBACK_DISABLE_CONFIG_WINDOW_COMPACT_MODE) is True: + config_window.CALLBACK_DISABLE_CONFIG_WINDOW_COMPACT_MODE() + + + config_window.setting_box_compact_mode_button_container = CTkFrame(parent_widget, corner_radius=0, fg_color=settings.ctm.TOP_BAR_BG_COLOR, width=0, height=0) config_window.setting_box_compact_mode_button_container.grid(row=0, column=1, padx=(0, 20), sticky="nsw") @@ -44,7 +55,7 @@ def _createSettingBoxCompactModeButton(parent_widget, config_window, settings): switch_height=16, onvalue=True, offvalue=False, - # command=command, + command=switchConfigWindowCompactMode, # fg_color="", # bg_color="red", progress_color=settings.ctm.SB__SWITCH_BOX_ACTIVE_BG_COLOR, # SB__SWITCH_BOX_ACTIVE_BG_COLOR is for SB. change it later. diff --git a/vrct_gui/vrct_gui.py b/vrct_gui/vrct_gui.py index dad8a8a6..4f6dbe32 100644 --- a/vrct_gui/vrct_gui.py +++ b/vrct_gui/vrct_gui.py @@ -106,11 +106,11 @@ class VRCT_GUI(CTk): ) def setDefaultActiveLanguagePresetTab(self, tab_no:str): - vrct_gui.current_active_preset_tab = getattr(self, f"sqls__presets_button_{tab_no}") + self.current_active_preset_tab = getattr(self, f"sqls__presets_button_{tab_no}") _setDefaultActiveTab( - active_tab_widget=vrct_gui.current_active_preset_tab, - active_bg_color=vrct_gui.settings.main.ctm.SQLS__PRESETS_TAB_BG_ACTIVE_COLOR, - active_text_color=vrct_gui.settings.main.ctm.SQLS__PRESETS_TAB_ACTIVE_TEXT_COLOR + active_tab_widget=self.current_active_preset_tab, + active_bg_color=self.settings.main.ctm.SQLS__PRESETS_TAB_BG_ACTIVE_COLOR, + active_text_color=self.settings.main.ctm.SQLS__PRESETS_TAB_ACTIVE_TEXT_COLOR )