From 84ebe47b8958a6a8def0773d1090f1c12562722f Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Tue, 5 Sep 2023 06:57:56 +0900 Subject: [PATCH] =?UTF-8?q?[Add]=20Config=20Window=20=E3=82=B9=E3=83=AC?= =?UTF-8?q?=E3=83=83=E3=82=B7=E3=83=A7=E3=83=AB=E3=83=89=E3=83=81=E3=82=A7?= =?UTF-8?q?=E3=83=83=E3=82=AF=E6=99=82=E3=81=AE=E3=83=9C=E3=82=BF=E3=83=B3?= =?UTF-8?q?=E3=81=AE=E3=82=B9=E3=83=86=E3=83=BC=E3=82=BF=E3=82=B9=E5=A4=89?= =?UTF-8?q?=E6=9B=B4(disabled,=20normal)=E9=96=A2=E6=95=B0=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E3=81=A8=E5=87=A6=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 21 +++++++++ view.py | 44 +++++++++++++++++++ vrct_gui/_changeConfigWindowWidgetsStatus.py | 37 ++++++++++++++++ .../createSettingBox_Mic.py | 34 ++------------ .../createSettingBox_Speaker.py | 35 ++------------- vrct_gui/vrct_gui.py | 10 +++++ 6 files changed, 118 insertions(+), 63 deletions(-) create mode 100644 vrct_gui/_changeConfigWindowWidgetsStatus.py diff --git a/main.py b/main.py index 2c6629f9..b9ae536a 100644 --- a/main.py +++ b/main.py @@ -270,9 +270,19 @@ def setProgressBarMicEnergy(energy): def callbackCheckMicThreshold(is_turned_on): print("callbackCheckMicThreshold", is_turned_on) if is_turned_on is True: + view.setConfigWindowCompactModeSwitchStatusToDisabled() + + view.setConfigWindowThresholdCheckWidgetsStatusToDisabled() model.startCheckMicEnergy(setProgressBarMicEnergy) + view.replaceConfigWindowMicThresholdCheckButtonToActive() + view.setConfigWindowThresholdCheckWidgetsStatusToNormal() else: + view.setConfigWindowThresholdCheckWidgetsStatusToDisabled() model.stopCheckMicEnergy() + view.replaceConfigWindowMicThresholdCheckButtonToPassive() + view.setConfigWindowThresholdCheckWidgetsStatusToNormal() + + view.setConfigWindowCompactModeSwitchStatusToNormal() def callbackSetMicRecordTimeout(value): print("callbackSetMicRecordTimeout", int(value)) @@ -318,9 +328,20 @@ def setProgressBarSpeakerEnergy(energy): def callbackCheckSpeakerThreshold(is_turned_on): print("callbackCheckSpeakerThreshold", is_turned_on) if is_turned_on is True: + view.setConfigWindowCompactModeSwitchStatusToDisabled() + + view.setConfigWindowThresholdCheckWidgetsStatusToDisabled() model.startCheckSpeakerEnergy(setProgressBarSpeakerEnergy) + view.replaceConfigWindowSpeakerThresholdCheckButtonToActive() + view.setConfigWindowThresholdCheckWidgetsStatusToNormal() + else: + view.setConfigWindowThresholdCheckWidgetsStatusToDisabled() model.stopCheckSpeakerEnergy() + view.replaceConfigWindowSpeakerThresholdCheckButtonToPassive() + view.setConfigWindowThresholdCheckWidgetsStatusToNormal() + + view.setConfigWindowCompactModeSwitchStatusToNormal() def callbackSetSpeakerRecordTimeout(value): print("callbackSetSpeakerRecordTimeout", int(value)) diff --git a/view.py b/view.py index f550180c..8202ce67 100644 --- a/view.py +++ b/view.py @@ -403,6 +403,50 @@ class View(): # Config Window + def setConfigWindowCompactModeSwitchStatusToDisabled(self): + vrct_gui.config_window.setting_box_compact_mode_switch_box.configure(state="disabled") + + def setConfigWindowCompactModeSwitchStatusToNormal(self): + vrct_gui.config_window.setting_box_compact_mode_switch_box.configure(state="normal") + + def setConfigWindowThresholdCheckWidgetsStatusToDisabled(self): + vrct_gui.changeConfigWindowWidgetsStatus( + status="disabled", + target_names=[ + "mic_energy_threshold_check_button", + "speaker_energy_threshold_check_button", + ] + ) + + def setConfigWindowThresholdCheckWidgetsStatusToNormal(self): + vrct_gui.changeConfigWindowWidgetsStatus( + status="normal", + target_names=[ + "mic_energy_threshold_check_button", + "speaker_energy_threshold_check_button", + ] + ) + + def replaceConfigWindowMicThresholdCheckButtonToActive(self): + vrct_gui.config_window.sb__progressbar_x_slider__passive_button_mic_energy_threshold.grid_remove() + vrct_gui.config_window.sb__progressbar_x_slider__active_button_mic_energy_threshold.grid() + + def replaceConfigWindowMicThresholdCheckButtonToPassive(self): + vrct_gui.config_window.sb__progressbar_x_slider__active_button_mic_energy_threshold.grid_remove() + vrct_gui.config_window.sb__progressbar_x_slider__passive_button_mic_energy_threshold.grid() + + + + def replaceConfigWindowSpeakerThresholdCheckButtonToActive(self): + vrct_gui.config_window.sb__progressbar_x_slider__passive_button_speaker_energy_threshold.grid_remove() + vrct_gui.config_window.sb__progressbar_x_slider__active_button_speaker_energy_threshold.grid() + + def replaceConfigWindowSpeakerThresholdCheckButtonToPassive(self): + vrct_gui.config_window.sb__progressbar_x_slider__active_button_speaker_energy_threshold.grid_remove() + vrct_gui.config_window.sb__progressbar_x_slider__passive_button_speaker_energy_threshold.grid() + + + def reloadConfigWindowSettingBoxContainer(self): vrct_gui.config_window.settings.IS_CONFIG_WINDOW_COMPACT_MODE = config.IS_CONFIG_WINDOW_COMPACT_MODE vrct_gui.config_window.reloadConfigWindowSettingBoxContainer() diff --git a/vrct_gui/_changeConfigWindowWidgetsStatus.py b/vrct_gui/_changeConfigWindowWidgetsStatus.py new file mode 100644 index 00000000..6eb2bd57 --- /dev/null +++ b/vrct_gui/_changeConfigWindowWidgetsStatus.py @@ -0,0 +1,37 @@ +from customtkinter import CTkImage + +from .ui_utils import getImageFileFromUiUtils + + +def _changeConfigWindowWidgetsStatus(config_window, settings, view_variable, status, target_names): + if target_names == "All": + target_names = ["mic_energy_threshold_check_button", "speaker_energy_threshold_check_button"] + + + for target_name in target_names: + match target_name: + case "mic_energy_threshold_check_button": + if status == "disabled": + config_window.sb__progressbar_x_slider__passive_button_mic_energy_threshold.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR) + config_window.sb__progressbar_x_slider__passive_button_mic_energy_threshold.children["!ctklabel"].configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR) + + elif status == "normal": + config_window.sb__progressbar_x_slider__passive_button_mic_energy_threshold.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_COLOR) + config_window.sb__progressbar_x_slider__passive_button_mic_energy_threshold.children["!ctklabel"].configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_COLOR) + + case "speaker_energy_threshold_check_button": + if status == "disabled": + config_window.sb__progressbar_x_slider__passive_button_speaker_energy_threshold.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR) + config_window.sb__progressbar_x_slider__passive_button_speaker_energy_threshold.children["!ctklabel"].configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR) + + elif status == "normal": + config_window.sb__progressbar_x_slider__passive_button_speaker_energy_threshold.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_COLOR) + config_window.sb__progressbar_x_slider__passive_button_speaker_energy_threshold.children["!ctklabel"].configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_COLOR) + + + case _: + raise ValueError(f"No matching case for target_name: {target_name}") + + + + config_window.update() \ 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 1ca96a8c..689452ca 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 @@ -10,27 +10,9 @@ def createSettingBox_Mic(setting_box_wrapper, config_window, settings, view_vari createSettingBoxEntry = sbg.createSettingBoxEntry - def checkbox_input_mic_threshold_check_callback(e, passive_button_wrapper_widget, active_button_wrapper_widget, is_turned_on): + def checkbox_input_mic_threshold_check_callback(is_turned_on): callFunctionIfCallable(view_variable.CALLBACK_CHECK_MIC_THRESHOLD, is_turned_on) - if is_turned_on is True: - passive_button_widget = passive_button_wrapper_widget.children["!ctklabel"] - passive_button_wrapper_widget.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR) - passive_button_widget.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR) - passive_button_wrapper_widget.update_idletasks() - - passive_button_wrapper_widget.grid_remove() - active_button_wrapper_widget.grid() - - elif is_turned_on is False: - # active_button_widget = active_button_wrapper_widget.children["!ctklabel"] - # active_button_wrapper_widget.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR) - # active_button_widget.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR) - # active_button_wrapper_widget.update_idletasks() - # sleep(3) - - active_button_wrapper_widget.grid_remove() - passive_button_wrapper_widget.grid() def optionmenu_mic_host_callback(value): callFunctionIfCallable(view_variable.CALLBACK_SET_MIC_HOST, value) @@ -102,19 +84,9 @@ def createSettingBox_Mic(setting_box_wrapper, config_window, settings, view_vari progressbar_attr_name="sb__progressbar_x_slider__progressbar_mic_energy_threshold", passive_button_attr_name="sb__progressbar_x_slider__passive_button_mic_energy_threshold", - passive_button_command=lambda e: checkbox_input_mic_threshold_check_callback( - e, - config_window.sb__progressbar_x_slider__passive_button_mic_energy_threshold, - config_window.sb__progressbar_x_slider__active_button_mic_energy_threshold, - is_turned_on=True, - ), + passive_button_command=lambda _e: checkbox_input_mic_threshold_check_callback(True), active_button_attr_name="sb__progressbar_x_slider__active_button_mic_energy_threshold", - active_button_command=lambda e: checkbox_input_mic_threshold_check_callback( - e, - config_window.sb__progressbar_x_slider__passive_button_mic_energy_threshold, - config_window.sb__progressbar_x_slider__active_button_mic_energy_threshold, - is_turned_on=False, - ), + active_button_command=lambda _e: checkbox_input_mic_threshold_check_callback(False), button_image_file=settings.image_file.MIC_ICON ) config_window.sb__mic_energy_threshold.grid(row=row) 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 911c10f1..5742292a 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,4 +1,3 @@ - from utils import callFunctionIfCallable from .._SettingBoxGenerator import _SettingBoxGenerator @@ -11,27 +10,9 @@ def createSettingBox_Speaker(setting_box_wrapper, config_window, settings, view_ createSettingBoxEntry = sbg.createSettingBoxEntry - def checkbox_input_speaker_threshold_check_callback(e, passive_button_wrapper_widget, active_button_wrapper_widget, is_turned_on): + def checkbox_input_speaker_threshold_check_callback(is_turned_on): callFunctionIfCallable(view_variable.CALLBACK_CHECK_SPEAKER_THRESHOLD, is_turned_on) - if is_turned_on is True: - passive_button_widget = passive_button_wrapper_widget.children["!ctklabel"] - passive_button_wrapper_widget.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR) - passive_button_widget.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR) - passive_button_wrapper_widget.update_idletasks() - - passive_button_wrapper_widget.grid_remove() - active_button_wrapper_widget.grid() - - elif is_turned_on is False: - # active_button_widget = active_button_wrapper_widget.children["!ctklabel"] - # active_button_wrapper_widget.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR) - # active_button_widget.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR) - # active_button_wrapper_widget.update_idletasks() - # sleep(3) - - active_button_wrapper_widget.grid_remove() - passive_button_wrapper_widget.grid() def optionmenu_input_speaker_device_callback(value): callFunctionIfCallable(view_variable.CALLBACK_SET_SPEAKER_DEVICE, value) @@ -84,19 +65,9 @@ def createSettingBox_Speaker(setting_box_wrapper, config_window, settings, view_ progressbar_attr_name="sb__progressbar_x_slider__progressbar_speaker_energy_threshold", passive_button_attr_name="sb__progressbar_x_slider__passive_button_speaker_energy_threshold", - passive_button_command=lambda e: checkbox_input_speaker_threshold_check_callback( - e, - config_window.sb__progressbar_x_slider__passive_button_speaker_energy_threshold, - config_window.sb__progressbar_x_slider__active_button_speaker_energy_threshold, - is_turned_on=True, - ), + passive_button_command=lambda _e: checkbox_input_speaker_threshold_check_callback(True), active_button_attr_name="sb__progressbar_x_slider__active_button_speaker_energy_threshold", - active_button_command=lambda e: checkbox_input_speaker_threshold_check_callback( - e, - config_window.sb__progressbar_x_slider__passive_button_speaker_energy_threshold, - config_window.sb__progressbar_x_slider__active_button_speaker_energy_threshold, - is_turned_on=False, - ), + active_button_command=lambda _e: checkbox_input_speaker_threshold_check_callback(False), button_image_file=settings.image_file.HEADPHONES_ICON ) config_window.sb__speaker_energy_threshold.grid(row=row) diff --git a/vrct_gui/vrct_gui.py b/vrct_gui/vrct_gui.py index c3e6afde..61631efb 100644 --- a/vrct_gui/vrct_gui.py +++ b/vrct_gui/vrct_gui.py @@ -6,6 +6,7 @@ from customtkinter import CTk # from .ui_managers import ColorThemeManager, ImageFileManager, UiScalingManager from ._changeMainWindowWidgetsStatus import _changeMainWindowWidgetsStatus +from ._changeConfigWindowWidgetsStatus import _changeConfigWindowWidgetsStatus from ._printToTextbox import _printToTextbox from .main_window import createMainWindowWidgets @@ -62,6 +63,15 @@ class VRCT_GUI(CTk): target_names=target_names, ) + def changeConfigWindowWidgetsStatus(self, status, target_names): + _changeConfigWindowWidgetsStatus( + config_window=self.config_window, + settings=self.settings.config_window, + view_variable=self._view_variable, + status=status, + target_names=target_names, + ) + def printToTextbox(self, target_textbox, original_message, translated_message, tags=None): _printToTextbox( settings=self.settings.main,