diff --git a/main.py b/main.py index 94d943cd..5cefaa00 100644 --- a/main.py +++ b/main.py @@ -425,7 +425,7 @@ def callbackSetMicRecordTimeout(value): if 0 <= value and value <= config.INPUT_MIC_PHRASE_TIMEOUT: view.clearErrorMessage() config.INPUT_MIC_RECORD_TIMEOUT = value - view.setGuiVariable_MicRecordTimeout(str(config.INPUT_MIC_RECORD_TIMEOUT)) + view.setGuiVariable_MicRecordTimeout(config.INPUT_MIC_RECORD_TIMEOUT) else: raise ValueError() except: @@ -438,7 +438,7 @@ def callbackSetMicPhraseTimeout(value): if 0 <= value and value >= config.INPUT_MIC_RECORD_TIMEOUT: view.clearErrorMessage() config.INPUT_MIC_PHRASE_TIMEOUT = value - view.setGuiVariable_MicPhraseTimeout(str(config.INPUT_MIC_PHRASE_TIMEOUT)) + view.setGuiVariable_MicPhraseTimeout(config.INPUT_MIC_PHRASE_TIMEOUT) else: raise ValueError() except: @@ -451,7 +451,7 @@ def callbackSetMicMaxPhrases(value): if 0 <= value: view.clearErrorMessage() config.INPUT_MIC_MAX_PHRASES = value - view.setGuiVariable_MicMaxPhrases(str(config.INPUT_MIC_MAX_PHRASES)) + view.setGuiVariable_MicMaxPhrases(config.INPUT_MIC_MAX_PHRASES) else: raise ValueError() except: @@ -505,7 +505,6 @@ def callbackCheckSpeakerThreshold(is_turned_on): model.startCheckSpeakerEnergy(setProgressBarSpeakerEnergy) view.replaceSpeakerThresholdCheckButton_Active() view.setWidgetsStatus_ThresholdCheckButton_Normal() - else: view.setWidgetsStatus_ThresholdCheckButton_Disabled() model.stopCheckSpeakerEnergy() @@ -519,7 +518,7 @@ def callbackSetSpeakerRecordTimeout(value): if 0 <= value and value <= config.INPUT_SPEAKER_PHRASE_TIMEOUT: view.clearErrorMessage() config.INPUT_SPEAKER_RECORD_TIMEOUT = value - view.setGuiVariable_SpeakerRecordTimeout(str(config.INPUT_SPEAKER_RECORD_TIMEOUT)) + view.setGuiVariable_SpeakerRecordTimeout(config.INPUT_SPEAKER_RECORD_TIMEOUT) else: raise ValueError() except: @@ -532,7 +531,7 @@ def callbackSetSpeakerPhraseTimeout(value): if 0 <= value and value >= config.INPUT_SPEAKER_RECORD_TIMEOUT: view.clearErrorMessage() config.INPUT_SPEAKER_PHRASE_TIMEOUT = value - view.setGuiVariable_SpeakerPhraseTimeout(str(config.INPUT_SPEAKER_PHRASE_TIMEOUT)) + view.setGuiVariable_SpeakerPhraseTimeout(config.INPUT_SPEAKER_PHRASE_TIMEOUT) else: raise ValueError() except: @@ -545,7 +544,7 @@ def callbackSetSpeakerMaxPhrases(value): if 0 <= value: view.clearErrorMessage() config.INPUT_SPEAKER_MAX_PHRASES = value - view.setGuiVariable_SpeakerMaxPhrases(str(config.INPUT_SPEAKER_MAX_PHRASES)) + view.setGuiVariable_SpeakerMaxPhrases(config.INPUT_SPEAKER_MAX_PHRASES) else: raise ValueError() except: diff --git a/view.py b/view.py index 88661660..dd32167b 100644 --- a/view.py +++ b/view.py @@ -728,8 +728,8 @@ class View(): - def setGuiVariable_MicEnergyThreshold(self, value:int): - self.view_variable.VAR_MIC_ENERGY_THRESHOLD__SLIDER.set(value) + def setGuiVariable_MicEnergyThreshold(self, value): + self.view_variable.VAR_MIC_ENERGY_THRESHOLD__SLIDER.set(int(value)) self.view_variable.VAR_MIC_ENERGY_THRESHOLD__ENTRY.set(str(value)) def setLatestConfigVariable_MicEnergyThreshold(self, _e=None): @@ -737,8 +737,8 @@ class View(): self.clearErrorMessage() - def setGuiVariable_SpeakerEnergyThreshold(self, value:int): - self.view_variable.VAR_SPEAKER_ENERGY_THRESHOLD__SLIDER.set(value) + def setGuiVariable_SpeakerEnergyThreshold(self, value): + self.view_variable.VAR_SPEAKER_ENERGY_THRESHOLD__SLIDER.set(int(value)) self.view_variable.VAR_SPEAKER_ENERGY_THRESHOLD__ENTRY.set(str(value)) def setLatestConfigVariable_SpeakerEnergyThreshold(self, _e=None): @@ -747,27 +747,27 @@ class View(): - def setGuiVariable_MicRecordTimeout(self, value:str="", delete=False): + def setGuiVariable_MicRecordTimeout(self, value, delete=False): if delete is True: self._clearEntryBox(vrct_gui.config_window.sb__entry_mic_record_timeout) - self.view_variable.VAR_MIC_RECORD_TIMEOUT.set(value) + self.view_variable.VAR_MIC_RECORD_TIMEOUT.set(str(value)) def setLatestConfigVariable_MicRecordTimeout(self, _e=None): self.setGuiVariable_MicRecordTimeout(config.INPUT_MIC_RECORD_TIMEOUT) self.clearErrorMessage() - def setGuiVariable_MicPhraseTimeout(self, value:str="", delete=False): + def setGuiVariable_MicPhraseTimeout(self, value, delete=False): if delete is True: self._clearEntryBox(vrct_gui.config_window.sb__entry_mic_phrase_timeout) - self.view_variable.VAR_MIC_PHRASE_TIMEOUT.set(value) + self.view_variable.VAR_MIC_PHRASE_TIMEOUT.set(str(value)) def setLatestConfigVariable_MicPhraseTimeout(self, _e=None): self.setGuiVariable_MicPhraseTimeout(config.INPUT_MIC_PHRASE_TIMEOUT) self.clearErrorMessage() - def setGuiVariable_MicMaxPhrases(self, value:str="", delete=False): + def setGuiVariable_MicMaxPhrases(self, value, delete=False): if delete is True: self._clearEntryBox(vrct_gui.config_window.sb__entry_mic_max_phrases) - self.view_variable.VAR_MIC_MAX_PHRASES.set(value) + self.view_variable.VAR_MIC_MAX_PHRASES.set(str(value)) def setLatestConfigVariable_MicMaxPhrases(self, _e=None): self.setGuiVariable_MicMaxPhrases(config.INPUT_MIC_MAX_PHRASES) @@ -775,27 +775,27 @@ class View(): - def setGuiVariable_SpeakerRecordTimeout(self, value:str="", delete=False): + def setGuiVariable_SpeakerRecordTimeout(self, value, delete=False): if delete is True: self._clearEntryBox(vrct_gui.config_window.sb__entry_speaker_record_timeout) - self.view_variable.VAR_SPEAKER_RECORD_TIMEOUT.set(value) + self.view_variable.VAR_SPEAKER_RECORD_TIMEOUT.set(str(value)) def setLatestConfigVariable_SpeakerRecordTimeout(self, _e=None): self.setGuiVariable_SpeakerRecordTimeout(config.INPUT_SPEAKER_RECORD_TIMEOUT) self.clearErrorMessage() - def setGuiVariable_SpeakerPhraseTimeout(self, value:str="", delete=False): + def setGuiVariable_SpeakerPhraseTimeout(self, value, delete=False): if delete is True: self._clearEntryBox(vrct_gui.config_window.sb__entry_speaker_phrase_timeout) - self.view_variable.VAR_SPEAKER_PHRASE_TIMEOUT.set(value) + self.view_variable.VAR_SPEAKER_PHRASE_TIMEOUT.set(str(value)) def setLatestConfigVariable_SpeakerPhraseTimeout(self, _e=None): self.setGuiVariable_SpeakerPhraseTimeout(config.INPUT_SPEAKER_PHRASE_TIMEOUT) self.clearErrorMessage() - def setGuiVariable_SpeakerMaxPhrases(self, value:str="", delete=False): + def setGuiVariable_SpeakerMaxPhrases(self, value, delete=False): if delete is True: self._clearEntryBox(vrct_gui.config_window.sb__entry_speaker_max_phrases) - self.view_variable.VAR_SPEAKER_MAX_PHRASES.set(value) + self.view_variable.VAR_SPEAKER_MAX_PHRASES.set(str(value)) def setLatestConfigVariable_SpeakerMaxPhrases(self, _e=None): self.setGuiVariable_SpeakerMaxPhrases(config.INPUT_SPEAKER_MAX_PHRASES) diff --git a/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py b/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py index 9501f9f6..2ebf4d04 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 +from ....ui_utils import bindEnterAndLeaveColor, bindButtonPressColor, bindButtonReleaseFunction, switchActiveTabAndPassiveTab, switchTabsColor, createOptionMenuBox from utils import callFunctionIfCallable @@ -51,69 +51,55 @@ def createSidebarLanguagesSettings(settings, main_window, view_variable): def createLanguageSettingBox(parent_widget, var_title_text, title_text_attr_name, arrow_img_attr_name, open_selectable_language_window_command, variable): sls__box = CTkFrame(parent_widget, corner_radius=0, fg_color=settings.ctm.SLS__BOX_BG_COLOR, width=0, height=0) - sls__box.columnconfigure((0,2), weight=1) + sls__box.columnconfigure(1, weight=1) sls__box_wrapper = CTkFrame(sls__box, corner_radius=0, fg_color=settings.ctm.SLS__BOX_BG_COLOR, width=0, height=0) - sls__box_wrapper.grid(row=2, column=1, padx=10, pady=settings.uism.SLS__BOX_IPADY) + sls__box_wrapper.grid(row=2, column=1, padx=10, pady=settings.uism.SLS__BOX_IPADY, sticky="ew") + + sls__box_wrapper.grid_columnconfigure(0, weight=1) + sls__box_label_wrapper = CTkFrame(sls__box_wrapper, corner_radius=0, fg_color=settings.ctm.SLS__BOX_BG_COLOR, width=0, height=0) + sls__box_label_wrapper.grid(row=0, column=0) + + sls__box_label_wrapper.grid_columnconfigure((0,2), weight=1) sls__label = CTkLabel( - sls__box_wrapper, + sls__box_label_wrapper, textvariable=var_title_text, height=0, font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.SLS__BOX_SECTION_TITLE_FONT_SIZE, weight="normal"), text_color=settings.ctm.SLS__BOX_SECTION_TITLE_TEXT_COLOR ) - sls__label.grid(row=0, column=0, pady=(0,settings.uism.SLS__BOX_SECTION_TITLE_BOTTOM_PADY)) + sls__label.grid(row=0, column=1, pady=(0,settings.uism.SLS__BOX_SECTION_TITLE_BOTTOM_PADY)) setattr(main_window, title_text_attr_name, sls__label) + sls__box_optionmenu_wrapper = CTkFrame(sls__box_wrapper, corner_radius=0, fg_color=settings.ctm.SLS__BOX_BG_COLOR, width=0, height=0) + sls__box_optionmenu_wrapper.grid(row=1, column=0, sticky="ew") - sls__selected_language_box = CTkFrame(sls__box_wrapper, corner_radius=0, fg_color=settings.ctm.SLS__DROPDOWN_MENU_BG_COLOR, cursor="hand2") - sls__selected_language_box.grid(row=1, column=0) + sls__box_optionmenu_wrapper.grid_columnconfigure(0, weight=1) + sls__selected_language_box = createOptionMenuBox( + parent_widget=sls__box_optionmenu_wrapper, + optionmenu_bg_color=settings.ctm.SLS__OPTIONMENU_BG_COLOR, + optionmenu_hovered_bg_color=settings.ctm.SLS__OPTIONMENU_HOVERED_BG_COLOR, + optionmenu_clicked_bg_color=settings.ctm.SLS__OPTIONMENU_CLICKED_BG_COLOR, + optionmenu_ipadx=(0,0), + optionmenu_ipady=2, + variable=variable, + font_family=settings.FONT_FAMILY, + font_size=settings.uism.SLS__BOX_DROPDOWN_MENU_FONT_SIZE, + text_color=settings.ctm.LABELS_TEXT_COLOR, + image_file=settings.image_file.ARROW_LEFT.rotate(180), + image_size=(20,20), + command=open_selectable_language_window_command, - - sls__selected_language_box.columnconfigure(0, minsize=200) - sls__selected_language_box.rowconfigure(0, minsize=30) - sls__selected_language_label_frame = CTkFrame(sls__selected_language_box, corner_radius=0, fg_color=settings.ctm.SLS__DROPDOWN_MENU_BG_COLOR) - sls__selected_language_label_frame.grid(row=0, column=0) - - sls__selected_language_label = CTkLabel( - sls__selected_language_label_frame, - textvariable=variable, - height=0, - # anchor="center", - font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.SLS__BOX_DROPDOWN_MENU_FONT_SIZE, weight="normal"), - text_color=settings.ctm.LABELS_TEXT_COLOR + optionmenu_position="center", + setattr_widget=main_window, + image_widget_attr_name=arrow_img_attr_name, ) - sls__selected_language_label.grid(row=0, column=0, pady=2) - setattr(main_window, title_text_attr_name, sls__selected_language_label) - - - sls__selected_language_arrow_img = CTkLabel( - sls__selected_language_box, - text=None, - corner_radius=0, - height=0, - image=CTkImage((settings.image_file.ARROW_LEFT).rotate(180),size=(20,20)) - ) - setattr(main_window, arrow_img_attr_name, sls__selected_language_arrow_img) - - - - sls__selected_language_arrow_img.grid(row=0, column=1, padx=0, pady=0) - - - - - bindEnterAndLeaveColor([sls__selected_language_label_frame, sls__selected_language_box, sls__selected_language_label, sls__selected_language_arrow_img], settings.ctm.SLS__DROPDOWN_MENU_HOVERED_BG_COLOR, settings.ctm.SLS__DROPDOWN_MENU_BG_COLOR) - bindButtonPressColor([sls__selected_language_label_frame, sls__selected_language_box, sls__selected_language_label, sls__selected_language_arrow_img], settings.ctm.SLS__DROPDOWN_MENU_CLICKED_BG_COLOR, settings.ctm.SLS__DROPDOWN_MENU_HOVERED_BG_COLOR) - - - - bindButtonReleaseFunction([sls__selected_language_label_frame, sls__selected_language_box, sls__selected_language_label, sls__selected_language_arrow_img], open_selectable_language_window_command) + sls__selected_language_box.grid(row=0, column=0, sticky="ew") return sls__box @@ -141,8 +127,11 @@ def createSidebarLanguagesSettings(settings, main_window, view_variable): # Presets buttons main_window.sidebar_bg_container.grid_rowconfigure(2, weight=1) - main_window.sls__presets_buttons_box = CTkFrame(main_window.sls__container, corner_radius=0, fg_color=settings.ctm.SIDEBAR_BG_COLOR, width=0, height=0) - main_window.sls__presets_buttons_box.grid(row=1, column=0, sticky="ew") + main_window.sls__presets_buttons_container = CTkFrame(main_window.sls__container, corner_radius=0, fg_color=settings.ctm.SIDEBAR_BG_COLOR, width=0, height=30) + main_window.sls__presets_buttons_container.grid(row=1, column=0, sticky="nsew") + + main_window.sls__presets_buttons_box = CTkFrame(main_window.sls__presets_buttons_container, corner_radius=0, fg_color=settings.ctm.SIDEBAR_BG_COLOR, width=0, height=0) + main_window.sls__presets_buttons_box.place(relwidth=1, relx=0, rely=1.15, anchor="sw") main_window.sls__presets_buttons_box.grid_columnconfigure((0,1,2), weight=1) @@ -176,10 +165,10 @@ def createSidebarLanguagesSettings(settings, main_window, view_variable): preset_tab_attr_name, CTkFrame( main_window.sls__presets_buttons_box, - corner_radius=0, + corner_radius=6, fg_color=settings.ctm.SLS__PRESETS_TAB_BG_PASSIVE_COLOR, width=0, - height=30, + height=36, cursor="hand2", ) ) @@ -195,7 +184,7 @@ def createSidebarLanguagesSettings(settings, main_window, view_variable): anchor="center", text_color=settings.ctm.SLS__PRESETS_TAB_ACTIVE_TEXT_COLOR_PASSIVE ) - label_widget.place(relx=0.5, rely=0.5, anchor="center") + label_widget.place(relx=0.5, rely=0.44, anchor="center") diff --git a/vrct_gui/main_window/widgets/create_textbox.py b/vrct_gui/main_window/widgets/create_textbox.py index 76d50a8b..891e78cb 100644 --- a/vrct_gui/main_window/widgets/create_textbox.py +++ b/vrct_gui/main_window/widgets/create_textbox.py @@ -61,8 +61,8 @@ def createTextbox(settings, main_window, view_variable): main_window.main_textbox_container = CTkFrame(main_window.main_bg_container, corner_radius=0, fg_color=settings.ctm.MAIN_BG_COLOR, width=0, height=0) main_window.main_textbox_container.grid(row=1, column=0, sticky="nsew") - main_window.main_textbox_container.columnconfigure(0,weight=1) - main_window.main_textbox_container.rowconfigure(0,weight=1) + main_window.main_textbox_container.grid_columnconfigure(0,weight=1) + main_window.main_textbox_container.grid_rowconfigure(0,weight=1) main_window.textbox_switch_tabs_container = CTkFrame(main_window.main_topbar_center_container, corner_radius=0, fg_color=settings.ctm.MAIN_BG_COLOR, width=0, height=0) main_window.textbox_switch_tabs_container.place(relx=0.07, rely=1.15, anchor="sw") diff --git a/vrct_gui/ui_managers/ColorThemeManager.py b/vrct_gui/ui_managers/ColorThemeManager.py index c712b2d4..a94f5f8f 100644 --- a/vrct_gui/ui_managers/ColorThemeManager.py +++ b/vrct_gui/ui_managers/ColorThemeManager.py @@ -158,9 +158,9 @@ class ColorThemeManager(): self.main.SLS__BOX_SECTION_TITLE_TEXT_COLOR = self.DARK_400_COLOR self.main.SLS__BOX_ARROWS_TEXT_COLOR = self.DARK_500_COLOR - self.main.SLS__DROPDOWN_MENU_BG_COLOR = self.DARK_888_COLOR - self.main.SLS__DROPDOWN_MENU_HOVERED_BG_COLOR = self.DARK_875_COLOR - self.main.SLS__DROPDOWN_MENU_CLICKED_BG_COLOR = self.DARK_900_COLOR + self.main.SLS__OPTIONMENU_BG_COLOR = self.DARK_888_COLOR + self.main.SLS__OPTIONMENU_HOVERED_BG_COLOR = self.DARK_875_COLOR + self.main.SLS__OPTIONMENU_CLICKED_BG_COLOR = self.DARK_900_COLOR self.main.CONFIG_BUTTON_BG_COLOR = self.main.SIDEBAR_BG_COLOR @@ -343,7 +343,7 @@ class ColorThemeManager(): self.main.SLS__BOX_SECTION_TITLE_TEXT_COLOR = self.LIGHT_800_COLOR self.main.SLS__BOX_ARROWS_TEXT_COLOR = self.LIGHT_700_COLOR - self.main.SLS__DROPDOWN_MENU_BG_COLOR = self.LIGHT_500_COLOR + self.main.SLS__OPTIONMENU_BG_COLOR = self.LIGHT_500_COLOR self.main.CONFIG_BUTTON_BG_COLOR = self.main.SIDEBAR_BG_COLOR diff --git a/vrct_gui/ui_utils/ui_utils.py b/vrct_gui/ui_utils/ui_utils.py index 1955fbfa..a68d1743 100644 --- a/vrct_gui/ui_utils/ui_utils.py +++ b/vrct_gui/ui_utils/ui_utils.py @@ -1,7 +1,7 @@ from os import path as os_path from PIL.Image import open as Image_open, LANCZOS -from customtkinter import CTkFrame, CTkLabel, CTkImage +from customtkinter import CTkFrame, CTkLabel, CTkImage, CTkFont def getImagePath(file_name): # root\img\file_name @@ -140,3 +140,51 @@ def createButtonWithImage(parent_widget, button_fg_color, button_enter_color, bu ) return button_wrapper + + +def createOptionMenuBox(parent_widget, optionmenu_bg_color, optionmenu_hovered_bg_color, optionmenu_clicked_bg_color, optionmenu_ipadx, optionmenu_ipady, variable, font_family, font_size, text_color, image_file, image_size, command, optionmenu_position=None, setattr_widget=None, image_widget_attr_name=None): + + option_menu_box = CTkFrame(parent_widget, corner_radius=4, fg_color=optionmenu_bg_color, cursor="hand2") + + option_menu_box.grid_columnconfigure(0, weight=1) + option_menu_box.grid_rowconfigure(0, weight=1) + optionmenu_label_wrapper = CTkFrame(option_menu_box, corner_radius=0, fg_color=optionmenu_bg_color) + optionmenu_label_wrapper.grid(row=0, column=0, sticky="ew") + + LABEL_COLUMN=0 + if optionmenu_position == "center": + optionmenu_label_wrapper.grid_columnconfigure((0,2), weight=1) + LABEL_COLUMN=1 + + optionmenu_label_widget = CTkLabel( + optionmenu_label_wrapper, + textvariable=variable, + height=0, + font=CTkFont(family=font_family, size=font_size, weight="normal"), + text_color=text_color + ) + optionmenu_label_widget.grid(row=0, column=LABEL_COLUMN, padx=optionmenu_ipadx, pady=optionmenu_ipady) + + + optionmenu_img_widget = CTkLabel( + option_menu_box, + text=None, + corner_radius=0, + height=0, + image=CTkImage(image_file, size=image_size) + ) + + if image_widget_attr_name is not None: + setattr(setattr_widget, image_widget_attr_name, optionmenu_img_widget) + + optionmenu_img_widget.grid(row=0, column=1, padx=0, pady=0) + + + bindEnterAndLeaveColor([optionmenu_label_wrapper, option_menu_box, optionmenu_label_widget, optionmenu_img_widget], optionmenu_hovered_bg_color, optionmenu_bg_color) + bindButtonPressColor([optionmenu_label_wrapper, option_menu_box, optionmenu_label_widget, optionmenu_img_widget], optionmenu_clicked_bg_color, optionmenu_hovered_bg_color) + + + + bindButtonReleaseFunction([optionmenu_label_wrapper, option_menu_box, optionmenu_label_widget, optionmenu_img_widget], command) + + return option_menu_box \ No newline at end of file