From f185b2f475c58a79afddde74e063116b172adc36 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Thu, 12 Oct 2023 17:03:26 +0900 Subject: [PATCH 1/2] [Refactor] Remove the code that is no longer in use. --- controller.py | 4 ---- view.py | 19 ---------------- vrct_gui/_changeConfigWindowWidgetsStatus.py | 23 ++------------------ 3 files changed, 2 insertions(+), 44 deletions(-) diff --git a/controller.py b/controller.py index 80ce9dc8..05f1829f 100644 --- a/controller.py +++ b/controller.py @@ -424,12 +424,10 @@ def callbackCheckMicThreshold(is_turned_on): view.replaceMicThresholdCheckButton_Disabled() model.startCheckMicEnergy(setProgressBarMicEnergy, view.initProgressBar_MicEnergy) view.replaceMicThresholdCheckButton_Active() - view.setWidgetsStatus_ThresholdCheckButton_Normal() else: view.replaceMicThresholdCheckButton_Disabled() model.stopCheckMicEnergy() view.replaceMicThresholdCheckButton_Passive() - view.setWidgetsStatus_ThresholdCheckButton_Normal() def callbackSetMicRecordTimeout(value): print("callbackSetMicRecordTimeout", value) @@ -522,12 +520,10 @@ def callbackCheckSpeakerThreshold(is_turned_on): view.replaceSpeakerThresholdCheckButton_Disabled() model.startCheckSpeakerEnergy(setProgressBarSpeakerEnergy, view.initProgressBar_SpeakerEnergy) view.replaceSpeakerThresholdCheckButton_Active() - view.setWidgetsStatus_ThresholdCheckButton_Normal() else: view.replaceSpeakerThresholdCheckButton_Disabled() model.stopCheckSpeakerEnergy() view.replaceSpeakerThresholdCheckButton_Passive() - view.setWidgetsStatus_ThresholdCheckButton_Normal() def callbackSetSpeakerRecordTimeout(value): print("callbackSetSpeakerRecordTimeout", value) diff --git a/view.py b/view.py index bc8974a1..3a0187e4 100644 --- a/view.py +++ b/view.py @@ -718,25 +718,6 @@ class View(): vrct_gui.config_window.sb__speaker_dynamic_energy_threshold.grid(pady=(0,1)) vrct_gui.config_window.sb__speaker_energy_threshold.grid_remove() - @staticmethod - def setWidgetsStatus_ThresholdCheckButton_Disabled(): - vrct_gui._changeConfigWindowWidgetsStatus( - status="disabled", - target_names=[ - "mic_energy_threshold_check_button", - "speaker_energy_threshold_check_button", - ] - ) - - @staticmethod - def setWidgetsStatus_ThresholdCheckButton_Normal(): - vrct_gui._changeConfigWindowWidgetsStatus( - status="normal", - target_names=[ - "mic_energy_threshold_check_button", - "speaker_energy_threshold_check_button", - ] - ) def initMicThresholdCheckButton(self): diff --git a/vrct_gui/_changeConfigWindowWidgetsStatus.py b/vrct_gui/_changeConfigWindowWidgetsStatus.py index 0183c886..39ca924b 100644 --- a/vrct_gui/_changeConfigWindowWidgetsStatus.py +++ b/vrct_gui/_changeConfigWindowWidgetsStatus.py @@ -1,8 +1,8 @@ from customtkinter import CTkImage 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"] + # if target_names == "All": + # target_names = [] def disableOptionmenuWidget(target_widget): @@ -17,25 +17,6 @@ def _changeConfigWindowWidgetsStatus(config_window, settings, view_variable, sta 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 "sb__optionmenu_mic_host": if status == "disabled": target_widget = config_window.sb__widgets["sb__optionmenu_mic_host"] From 717a56a580e578d91eb427a8d106c736d76d6cb8 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Fri, 13 Oct 2023 05:59:14 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[bugfix]=20fix=201px=20bugs.=20(=E3=81=BE?= =?UTF-8?q?=E3=81=A0=E7=99=BA=E7=94=9F=E3=81=99=E3=82=8B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vrct_gui/_CreateSelectableLanguagesWindow.py | 6 +++--- vrct_gui/config_window/ConfigWindow.py | 9 ++++++--- .../_createSettingBoxCompactModeButton.py | 4 ++-- .../_createSettingBoxTitle.py | 8 ++++++-- .../createSettingBoxTopBar.py | 19 +++++++++++++++++-- .../_addConfigSideMenuItem.py | 3 --- .../createSideMenuAndSettingsBoxContainers.py | 4 ++-- .../createSidebarLanguagesSettings.py | 5 ++++- vrct_gui/vrct_gui.py | 6 +++--- 9 files changed, 43 insertions(+), 21 deletions(-) diff --git a/vrct_gui/_CreateSelectableLanguagesWindow.py b/vrct_gui/_CreateSelectableLanguagesWindow.py index 51fdd1f9..0ba102b4 100644 --- a/vrct_gui/_CreateSelectableLanguagesWindow.py +++ b/vrct_gui/_CreateSelectableLanguagesWindow.py @@ -1,7 +1,7 @@ from functools import partial from .ui_utils import bindButtonReleaseFunction, bindEnterAndLeaveColor, bindButtonPressColor, applyUiScalingAndFixTheBugScrollBar -from utils import callFunctionIfCallable +from utils import callFunctionIfCallable, makeEven from customtkinter import CTkToplevel, CTkFrame, CTkLabel, CTkFont, CTkScrollableFrame @@ -39,8 +39,8 @@ class _CreateSelectableLanguagesWindow(CTkToplevel): self.attach.update_idletasks() self.x_pos = self.attach.winfo_rootx() self.y_pos = self.attach.winfo_rooty() - self.width_new = self.attach.winfo_width() - self.height_new = self.attach.winfo_height() + self.width_new = makeEven(self.attach.winfo_width()) + self.height_new = makeEven(self.attach.winfo_height()) self.geometry("{}x{}+{}+{}".format(self.width_new, self.height_new, self.x_pos, self.y_pos)) diff --git a/vrct_gui/config_window/ConfigWindow.py b/vrct_gui/config_window/ConfigWindow.py index 463fb78a..6bf10df8 100644 --- a/vrct_gui/config_window/ConfigWindow.py +++ b/vrct_gui/config_window/ConfigWindow.py @@ -1,9 +1,9 @@ from .widgets import createConfigWindowTitle, createSideMenuAndSettingsBoxContainers, createSettingBoxTopBar -from customtkinter import CTkToplevel +from customtkinter import CTkToplevel, CTkFrame -from ..ui_utils import getImagePath +from ..ui_utils import getImagePath, getLatestWidth, getLatestHeight class ConfigWindow(CTkToplevel): def __init__(self, vrct_gui, settings, view_variable): @@ -32,8 +32,11 @@ class ConfigWindow(CTkToplevel): createSettingBoxTopBar(config_window=self, settings=self.settings, view_variable=self._view_variable) - createSideMenuAndSettingsBoxContainers(config_window=self, settings=self.settings, view_variable=self._view_variable) + # for fixing 1px bug + sls__box_optionmenu_wrapper_fix_1px_bug = CTkFrame(self.side_menu_bg_container, corner_radius=0, width=0, height=0) + sls__box_optionmenu_wrapper_fix_1px_bug.grid(row=1, column=0, sticky="ew") + self.bind_all("", lambda event: event.widget.focus_set(), "+") \ 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 6cdcd504..792ecc12 100644 --- a/vrct_gui/config_window/widgets/createSettingBoxTopBar/_createSettingBoxCompactModeButton.py +++ b/vrct_gui/config_window/widgets/createSettingBoxTopBar/_createSettingBoxCompactModeButton.py @@ -1,6 +1,6 @@ from customtkinter import CTkFont, CTkFrame, CTkLabel, CTkSwitch -def _createSettingBoxCompactModeButton(parent_widget, config_window, settings, view_variable): +def _createSettingBoxCompactModeButton(parent_widget, config_window, settings, view_variable, column_num): def switchConfigWindowCompactMode(): if config_window.setting_box_compact_mode_switch_box.get() is True: @@ -13,7 +13,7 @@ def _createSettingBoxCompactModeButton(parent_widget, config_window, settings, v 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=settings.uism.COMPACT_MODE_PADX, sticky="nsw") + config_window.setting_box_compact_mode_button_container.grid(row=0, column=column_num, padx=settings.uism.COMPACT_MODE_PADX, sticky="nsw") diff --git a/vrct_gui/config_window/widgets/createSettingBoxTopBar/_createSettingBoxTitle.py b/vrct_gui/config_window/widgets/createSettingBoxTopBar/_createSettingBoxTitle.py index 824da444..7c0ec386 100644 --- a/vrct_gui/config_window/widgets/createSettingBoxTopBar/_createSettingBoxTitle.py +++ b/vrct_gui/config_window/widgets/createSettingBoxTopBar/_createSettingBoxTitle.py @@ -1,10 +1,10 @@ from customtkinter import CTkFont, CTkFrame, CTkLabel -def _createSettingBoxTitle(parent_widget, config_window, settings, view_variable): +def _createSettingBoxTitle(parent_widget, config_window, settings, view_variable, column_num): parent_widget.grid_columnconfigure(0, weight=1) config_window.main_current_active_config_title_container = CTkFrame(parent_widget, corner_radius=0, fg_color=settings.ctm.TOP_BAR_BG_COLOR, width=0, height=0) - config_window.main_current_active_config_title_container.grid(row=0, column=0, sticky="nsew") + config_window.main_current_active_config_title_container.grid(row=0, column=column_num, sticky="nsew") config_window.main_current_active_config_title_container.grid_rowconfigure(0, weight=1) @@ -18,3 +18,7 @@ def _createSettingBoxTitle(parent_widget, config_window, settings, view_variable ) config_window.main_current_active_config_title.grid(row=0, column=0, padx=0, pady=settings.uism.TOP_BAR__IPADY) + + # for fixing 1px bug + sls__box_optionmenu_wrapper_fix_1px_bug = CTkFrame(config_window.main_current_active_config_title, corner_radius=0, width=0, height=0) + sls__box_optionmenu_wrapper_fix_1px_bug.grid(row=0, column=column_num, sticky="ns") \ No newline at end of file diff --git a/vrct_gui/config_window/widgets/createSettingBoxTopBar/createSettingBoxTopBar.py b/vrct_gui/config_window/widgets/createSettingBoxTopBar/createSettingBoxTopBar.py index d663d17d..8e0581e5 100644 --- a/vrct_gui/config_window/widgets/createSettingBoxTopBar/createSettingBoxTopBar.py +++ b/vrct_gui/config_window/widgets/createSettingBoxTopBar/createSettingBoxTopBar.py @@ -3,6 +3,9 @@ from customtkinter import CTkFont, CTkFrame, CTkLabel from ._createSettingBoxTitle import _createSettingBoxTitle from ._createSettingBoxCompactModeButton import _createSettingBoxCompactModeButton +from ....ui_utils import getLatestHeight, getLatestWidth +from utils import isEven + def createSettingBoxTopBar(config_window, settings, view_variable): config_window.grid_columnconfigure(1, weight=1) @@ -10,6 +13,18 @@ def createSettingBoxTopBar(config_window, settings, view_variable): config_window.setting_box_top_bar.grid(row=0, column=1, sticky="nsew") - _createSettingBoxTitle(parent_widget=config_window.setting_box_top_bar, config_window=config_window, settings=settings, view_variable=view_variable) + column_num=0 + _createSettingBoxTitle(parent_widget=config_window.setting_box_top_bar, config_window=config_window, settings=settings, view_variable=view_variable, column_num=column_num) + column_num+=1 - _createSettingBoxCompactModeButton(parent_widget=config_window.setting_box_top_bar, config_window=config_window, settings=settings, view_variable=view_variable) \ No newline at end of file + _createSettingBoxCompactModeButton(parent_widget=config_window.setting_box_top_bar, config_window=config_window, settings=settings, view_variable=view_variable, column_num=column_num) + column_num+=1 + + + l_height = getLatestHeight(config_window.side_menu_config_window_title_logo_frame) + if isEven(l_height) is False: + config_window.grid_rowconfigure(0, weight=0, minsize=l_height+1) + + # for fixing 1px bug + setting_box_top_bar_fix_1px_bug = CTkFrame(config_window.setting_box_top_bar, corner_radius=0, width=0, height=0) + setting_box_top_bar_fix_1px_bug.grid(row=0, column=column_num, sticky="ns") \ No newline at end of file diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/_addConfigSideMenuItem.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/_addConfigSideMenuItem.py index 4e5ec347..39d83009 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/_addConfigSideMenuItem.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/_addConfigSideMenuItem.py @@ -96,9 +96,6 @@ def _addConfigSideMenuItem(config_window, settings, view_variable, side_menu_set setattr(config_window, selected_mark_attr_name, selected_mark_widget) - - - # Arrange selected_mark_widget.place(relx=-1, rely=0.5, relheight=1, anchor="w") label_widget.grid(row=0, column=0, padx=settings.uism.SIDE_MENU_LABELS_IPADX, pady=settings.uism.SIDE_MENU_LABELS_IPADY, sticky="ew") diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/createSideMenuAndSettingsBoxContainers.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/createSideMenuAndSettingsBoxContainers.py index e5fb507d..6cfc489e 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/createSideMenuAndSettingsBoxContainers.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/createSideMenuAndSettingsBoxContainers.py @@ -30,9 +30,9 @@ def createSideMenuAndSettingsBoxContainers(config_window, settings, view_variabl config_window.side_menu_bg_container = CTkFrame(config_window, corner_radius=0, fg_color=settings.ctm.SIDE_MENU_BG_COLOR, width=0, height=0) config_window.side_menu_bg_container.grid(row=1, column=0, sticky="nsew") - + config_window.side_menu_bg_container.grid_rowconfigure(0, weight=1) config_window.side_menu_container = CTkFrame(config_window.side_menu_bg_container, corner_radius=0, fg_color=settings.ctm.SIDE_MENU_LABELS_BG_FOR_FAKE_BORDER_COLOR, width=0, height=0) - config_window.side_menu_container.grid(row=0, column=0, padx=settings.uism.TOP_BAR_SIDE__TITLE_PADX, pady=(settings.uism.SIDE_MENU_TOP_PADY, 0)) + config_window.side_menu_container.grid(row=0, column=0, padx=settings.uism.TOP_BAR_SIDE__TITLE_PADX, pady=(settings.uism.SIDE_MENU_TOP_PADY, 0), sticky="nsew") diff --git a/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py b/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py index 0363934e..98fda4ae 100644 --- a/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py +++ b/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py @@ -1,6 +1,6 @@ from customtkinter import CTkFont, CTkFrame, CTkLabel, CTkImage -from ....ui_utils import bindEnterAndLeaveColor, bindButtonPressColor, bindButtonReleaseFunction, switchActiveTabAndPassiveTab, switchTabsColor, createOptionMenuBox +from ....ui_utils import bindEnterAndLeaveColor, bindButtonPressColor, bindButtonReleaseFunction, switchActiveTabAndPassiveTab, switchTabsColor, createOptionMenuBox, getLatestWidth from utils import callFunctionIfCallable @@ -101,6 +101,9 @@ def createSidebarLanguagesSettings(settings, main_window, view_variable): ) sls__selected_language_box.grid(row=0, column=0, sticky="ew") + sls__box_optionmenu_wrapper_fix_1px_bug = CTkFrame(optionmenu_label_widget, corner_radius=0, width=0, height=0) + sls__box_optionmenu_wrapper_fix_1px_bug.grid(row=0, column=1, sticky="ns") + return sls__box diff --git a/vrct_gui/vrct_gui.py b/vrct_gui/vrct_gui.py index 844c029a..390d076b 100644 --- a/vrct_gui/vrct_gui.py +++ b/vrct_gui/vrct_gui.py @@ -13,7 +13,7 @@ from .main_window import createMainWindowWidgets from .config_window import ConfigWindow from .ui_utils import _setDefaultActiveTab, getLatestHeight, setGeometryToCenterOfScreen, fadeInAnimation -from utils import callFunctionIfCallable +from utils import callFunctionIfCallable, makeEven class VRCT_GUI(CTk): def __init__(self): @@ -238,8 +238,8 @@ class VRCT_GUI(CTk): self.update_idletasks() x_pos = self.winfo_rootx() y_pos = self.winfo_rooty() - width_new = self.winfo_width() - height_new = self.winfo_height() + width_new = makeEven(self.winfo_width()) + height_new = makeEven(self.winfo_height()) self.modal_window.geometry("{}x{}+{}+{}".format(width_new, height_new, x_pos, y_pos)) self.modal_window.lift()