From 6cd56991c35635e827f2580d3b7bb4d182f699be Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Sun, 14 Jan 2024 19:11:09 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[bugfix/chore]=20Main=20Window:=20Selectabl?= =?UTF-8?q?e=20Translation=20Engines.=20=E3=83=BB=E3=83=89=E3=83=AD?= =?UTF-8?q?=E3=83=83=E3=83=97=E3=83=80=E3=82=A6=E3=83=B3=E3=83=A1=E3=83=8B?= =?UTF-8?q?=E3=83=A5=E3=83=BC=E3=81=AE=E6=96=87=E8=A8=80=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E3=80=82=EF=BC=88CTranslate2=E3=81=AE=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=81=A8=E3=80=81=E3=83=87=E3=83=95=E3=82=A9?= =?UTF-8?q?=E3=83=AB=E3=83=88=E3=81=A7=E3=81=82=E3=82=8B=E6=97=A8=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=EF=BC=89=20=E3=83=BB=E5=B9=85=E3=81=8C?= =?UTF-8?q?=E8=A6=8F=E5=AE=9A=E5=80=A4=E3=82=88=E3=82=8A=E8=B6=85=E3=81=88?= =?UTF-8?q?=E3=81=9F=E6=99=82=E3=81=AE=E5=87=A6=E7=90=86=E3=81=A7=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E3=81=8C=E7=99=BA=E7=94=9F=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/en.yml | 2 +- locales/ja.yml | 2 +- view.py | 8 +++++- .../createSidebarLanguagesSettings.py | 22 ---------------- vrct_gui/ui_managers/UiScalingManager.py | 3 ++- vrct_gui/vrct_gui.py | 25 ++++++++++++++++++- 6 files changed, 35 insertions(+), 27 deletions(-) diff --git a/locales/en.yml b/locales/en.yml index fdb5f4aa..d967956d 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -10,7 +10,7 @@ main_window: swap_button_label: Swap Languages target_language: Target Language translator: Translator - translator_ctranslate2: Internal + translator_ctranslate2: Internal (Default) textbox_tab_all: All textbox_tab_sent: Sent diff --git a/locales/ja.yml b/locales/ja.yml index 72d79c41..4443c822 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -10,7 +10,7 @@ main_window: swap_button_label: 言語を入れ替え target_language: 相手の言語 translator: 翻訳エンジン - translator_ctranslate2: オフライン翻訳 + translator_ctranslate2: オフライン翻訳(デフォルト) textbox_tab_all: 全て textbox_tab_sent: 送信 diff --git a/view.py b/view.py index 16b913dd..76089ece 100644 --- a/view.py +++ b/view.py @@ -89,6 +89,12 @@ class View(): **common_args ) + self.settings.dropdown_menu_window = SimpleNamespace( + # ctm=all_ctm.dropdown_menu_window, + uism=all_uism.dropdown_menu_window, + **common_args + ) + self.view_variable = SimpleNamespace( # Common CALLBACK_RESTART_SOFTWARE=None, @@ -906,7 +912,7 @@ class View(): def updateSelectableTranslationEngineList(self, selectable_translation_engines_list): translation_dict = {item: item for item in selectable_translation_engines_list} - translation_dict["CTranslate2"] = self.TEXT_TRANSLATOR_CTRANSLATE2 + translation_dict["CTranslate2"] = i18n.t("main_window.translator_ctranslate2") vrct_gui.translation_engine_dropdown_menu_window.updateDropdownMenuValues( dropdown_menu_widget_id="translation_engine_dropdown_menu", diff --git a/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py b/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py index e6c6c691..0c3a8e25 100644 --- a/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py +++ b/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py @@ -352,28 +352,6 @@ def createSidebarLanguagesSettings(settings, main_window, view_variable): - main_window.translation_engine_dropdown_menu_window = _CreateDropdownMenuWindow( - settings=settings, - view_variable=main_window._view_variable, - - window_additional_y_pos=4, - window_border_width=1, - scrollbar_ipadx=(2,2), - scrollbar_width=16, - value_ipadx=(8,0), - value_ipady=(6,6), - value_pady=0, - value_font_size=14, - dropdown_menu_default_min_width=200, - - window_bg_color="#1f2022", - window_border_color="#7f8084", - values_bg_color="#323336", - values_hovered_bg_color="#4b4c4f", - values_clicked_bg_color="#292a2d", - values_text_color=settings.ctm.BASIC_TEXT_COLOR, - ) - # main_window.translation_engine_dropdown_menu_window = _CreateDropdownMenuWindow( # settings=settings.config_window, # view_variable=main_window._view_variable, diff --git a/vrct_gui/ui_managers/UiScalingManager.py b/vrct_gui/ui_managers/UiScalingManager.py index 64550683..8fea6a2c 100644 --- a/vrct_gui/ui_managers/UiScalingManager.py +++ b/vrct_gui/ui_managers/UiScalingManager.py @@ -13,6 +13,7 @@ class UiScalingManager(): self.main_window_cover = SimpleNamespace() self.error_message_window = SimpleNamespace() self.confirmation_modal = SimpleNamespace() + self.dropdown_menu_window = SimpleNamespace() self._calculatedUiSizes() @@ -170,7 +171,7 @@ class UiScalingManager(): self.confirmation_modal.BUTTONS_IPADY = self._calculateUiSize(6) # Dropdown Menu Window - self.config_window.MARGIN_WIDTH = self._calculateUiSize(16) + self.dropdown_menu_window.MARGIN_WIDTH = self._calculateUiSize(16) # Config Window self.config_window.DEFAULT_WIDTH = self._calculateUiSize(1080) diff --git a/vrct_gui/vrct_gui.py b/vrct_gui/vrct_gui.py index 7c0bdc7f..7a4970c4 100644 --- a/vrct_gui/vrct_gui.py +++ b/vrct_gui/vrct_gui.py @@ -71,14 +71,37 @@ class VRCT_GUI(CTk): self.settings = settings self._view_variable = view_variable + self.translation_engine_dropdown_menu_window = _CreateDropdownMenuWindow( + settings=settings.dropdown_menu_window, + view_variable=self._view_variable, + + window_additional_y_pos=4, + window_border_width=1, + scrollbar_ipadx=(2,2), + scrollbar_width=16, + value_ipadx=(8,0), + value_ipady=(6,6), + value_pady=0, + value_font_size=14, + dropdown_menu_default_min_width=200, + + window_bg_color="#1f2022", + window_border_color="#7f8084", + values_bg_color="#323336", + values_hovered_bg_color="#4b4c4f", + values_clicked_bg_color="#292a2d", + values_text_color=settings.main.ctm.BASIC_TEXT_COLOR, + ) + createMainWindowWidgets( vrct_gui=self, settings=self.settings.main, view_variable=self._view_variable ) + # For Config Window self.dropdown_menu_window = _CreateDropdownMenuWindow( - settings=self.settings.config_window, + settings=self.settings.dropdown_menu_window, view_variable=self._view_variable, window_additional_y_pos=self.settings.config_window.uism.SB__DROPDOWN_MENU_WINDOW_ADDITIONAL_Y_POS, From f2321fcbc43037da9d4d805d42a6cb22c5c6b012 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Mon, 15 Jan 2024 12:05:06 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[Update]=20Main=20Window:=20Selectable=20Tr?= =?UTF-8?q?anslation=20Engines.=20=E3=83=BBUI=E8=AA=BF=E6=95=B4=E3=80=81?= =?UTF-8?q?=E6=96=87=E8=A8=80=E5=A4=89=E6=9B=B4=E3=80=82=E6=97=A5=E6=9C=AC?= =?UTF-8?q?=E8=AA=9E=E3=81=AF=E5=B9=85=E3=82=92=E5=8F=96=E3=82=8A=E3=81=99?= =?UTF-8?q?=E3=81=8E=E3=82=8B=E3=81=AE=E3=81=A7=E3=80=81"=EF=BC=88?= =?UTF-8?q?=E3=83=87=E3=83=95=E3=82=A9=E3=83=AB=E3=83=88=EF=BC=89"?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=82=92"(Default)"=E3=81=A8=E8=8B=B1?= =?UTF-8?q?=E8=AA=9E=E8=A1=A8=E8=A8=98=E3=81=AB=E3=80=82=E4=BB=96=E3=81=AE?= =?UTF-8?q?=E8=A8=80=E8=AA=9E=E3=81=A8=E3=81=AE=E5=85=BC=E3=81=AD=E5=90=88?= =?UTF-8?q?=E3=81=84=E3=82=82=E3=81=82=E3=82=8B=E3=81=AE=E3=81=A7=E3=80=81?= =?UTF-8?q?=E4=BB=8A=E3=81=AF=E3=81=A8=E3=82=8A=E3=81=82=E3=81=88=E3=81=9A?= =?UTF-8?q?locales=E3=81=AEyml=E3=81=AB=E3=81=9D=E3=82=8C=E3=81=9E?= =?UTF-8?q?=E3=82=8C=E7=9B=B4=E6=8E=A5=E8=A8=98=E8=BF=B0=E3=80=82=20?= =?UTF-8?q?=E3=83=BBUI=20Scaling=E5=AF=BE=E5=BF=9C=20=E3=83=BBUI=20Theme(L?= =?UTF-8?q?ight)=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/ja.yml | 2 +- .../createSidebarLanguagesSettings.py | 61 ++++--------------- vrct_gui/ui_managers/Themes/_darkTheme.py | 5 ++ vrct_gui/ui_managers/Themes/_lightTheme.py | 5 ++ vrct_gui/ui_managers/UiScalingManager.py | 19 +++++- vrct_gui/ui_utils/ui_utils.py | 49 +++++++++++++++ vrct_gui/vrct_gui.py | 30 ++++----- 7 files changed, 106 insertions(+), 65 deletions(-) diff --git a/locales/ja.yml b/locales/ja.yml index 4443c822..25748b8e 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -10,7 +10,7 @@ main_window: swap_button_label: 言語を入れ替え target_language: 相手の言語 translator: 翻訳エンジン - translator_ctranslate2: オフライン翻訳(デフォルト) + translator_ctranslate2: オフライン翻訳 (Default) textbox_tab_all: 全て textbox_tab_sent: 送信 diff --git a/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py b/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py index 0c3a8e25..f529898f 100644 --- a/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py +++ b/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py @@ -2,7 +2,7 @@ from customtkinter import CTkFont, CTkFrame, CTkLabel, CTkImage from ...._CreateDropdownMenuWindow import _CreateDropdownMenuWindow -from ....ui_utils import bindEnterAndLeaveColor, bindButtonPressColor, bindButtonReleaseFunction, switchActiveTabAndPassiveTab, switchTabsColor, createOptionMenuBox, bindButtonFunctionAndColor, bindEnterAndLeaveFunction +from ....ui_utils import bindEnterAndLeaveColor, bindButtonPressColor, bindButtonReleaseFunction, switchActiveTabAndPassiveTab, switchTabsColor, createOptionMenuBox, bindButtonFunctionAndColor, bindEnterAndLeaveFunction, createLabelButton from utils import callFunctionIfCallable @@ -345,39 +345,13 @@ def createSidebarLanguagesSettings(settings, main_window, view_variable): sls__box_translation_optionmenu_wrapper = CTkFrame(main_window.sls__box_frame, corner_radius=0, fg_color=settings.ctm.SLS__BG_COLOR, width=0, height=0) - sls__box_translation_optionmenu_wrapper.grid(row=5, column=0, sticky="ew") + sls__box_translation_optionmenu_wrapper.grid(row=5, column=0, pady=settings.uism.SLS__SELECTABLE_TRANSLATION_PADY, sticky="ew") - sls__box_translation_optionmenu_wrapper.grid_columnconfigure((0,2), weight=1, minsize=settings.uism.SLS__BOX_ARROWS_SWAP_BUTTON_PADX) + sls__box_translation_optionmenu_wrapper.grid_columnconfigure((0,2), weight=0, minsize=settings.uism.SLS__SELECTABLE_TRANSLATION_MIN_PADX) sls__box_translation_optionmenu_wrapper.grid_columnconfigure(1, weight=1) - # main_window.translation_engine_dropdown_menu_window = _CreateDropdownMenuWindow( - # settings=settings.config_window, - # view_variable=main_window._view_variable, - - # window_additional_y_pos=settings.config_window.uism.SB__DROPDOWN_MENU_WINDOW_ADDITIONAL_Y_POS, - # window_border_width=settings.config_window.uism.SB__DROPDOWN_MENU_WINDOW_BORDER_WIDTH, - # scrollbar_ipadx=settings.config_window.uism.SB__DROPDOWN_MENU_SCROLLBAR_IPADX, - # scrollbar_width=settings.config_window.uism.SB__DROPDOWN_MENU_SCROLLBAR_WIDTH, - # value_ipadx=settings.config_window.uism.SB__DROPDOWN_MENU_VALUE_IPADX, - # value_ipady=settings.config_window.uism.SB__DROPDOWN_MENU_VALUE_IPADY, - # value_pady=settings.config_window.uism.SB__DROPDOWN_MENU_VALUE_PADY, - # value_font_size=settings.config_window.uism.SB__DROPDOWN_MENU_VALUE_FONT_SIZE, - # dropdown_menu_default_min_width=settings.config_window.uism.SB__DROPDOWN_MENU_VALUE_DEFAULT_MIN_WIDTH, - - # window_bg_color=settings.config_window.ctm.SB__DROPDOWN_MENU_WINDOW_BG_COLOR, - # window_border_color=settings.config_window.ctm.SB__DROPDOWN_MENU_WINDOW_BORDER_COLOR, - # values_bg_color=settings.config_window.ctm.SB__DROPDOWN_MENU_BG_COLOR, - # values_hovered_bg_color=settings.config_window.ctm.SB__DROPDOWN_MENU_HOVERED_BG_COLOR, - # values_clicked_bg_color=settings.config_window.ctm.SB__DROPDOWN_MENU_CLICKED_BG_COLOR, - # values_text_color=settings.config_window.ctm.BASIC_TEXT_COLOR, - # ) - - - - - def adjustedCommand(value): callFunctionIfCallable(view_variable.CALLBACK_SELECTED_TRANSLATION_ENGINE, value) @@ -388,34 +362,25 @@ def createSidebarLanguagesSettings(settings, main_window, view_variable): command=adjustedCommand, wrapper_widget=main_window, attach_widget=sls__box_translation_optionmenu_wrapper, - dropdown_menu_min_width=200, + dropdown_menu_min_width=settings.uism.SIDEBAR_MIN_WIDTH, ) - - - - (sls__selected_translation_engine_box, optionmenu_label_widget, optionmenu_img_widget) = createOptionMenuBox( + (sls__selected_translation_engine_box, label_button_label_widget) = createLabelButton( parent_widget=sls__box_translation_optionmenu_wrapper, - optionmenu_bg_color=settings.ctm.SLS__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,10), - optionmenu_ipady=6, + label_button_bg_color=settings.ctm.SLS__BG_COLOR, + label_button_hovered_bg_color=settings.ctm.SLS__OPTIONMENU_HOVERED_BG_COLOR, + label_button_clicked_bg_color=settings.ctm.SLS__OPTIONMENU_CLICKED_BG_COLOR, + label_button_ipadx=settings.uism.SLS__SELECTABLE_TRANSLATION_IPADX, + label_button_ipady=settings.uism.SLS__SELECTABLE_TRANSLATION_IPADY, variable=view_variable.VAR_SELECTED_TRANSLATION_ENGINE, font_family=settings.FONT_FAMILY, - font_size=12, + font_size=settings.uism.SLS__SELECTABLE_TRANSLATION_FONT_SIZE, text_color=settings.ctm.LABELS_TEXT_COLOR, - image_file=settings.image_file.REFRESH_ICON.rotate(45), - image_size=(14,14), - # image_size=settings.uism.SLS__BOX_OPTION_MENU_ARROW_IMAGE_SIZE, - optionmenu_clicked_command=lambda _e: main_window.translation_engine_dropdown_menu_window.show( + label_button_clicked_command=lambda _e: main_window.translation_engine_dropdown_menu_window.show( dropdown_menu_widget_id="translation_engine_dropdown_menu" ), - optionmenu_position="center", - setattr_widget=main_window, - image_widget_attr_name="sls__arrow_img_select", + label_button_position="center", ) sls__selected_translation_engine_box.grid(row=0, column=1, sticky="ew") - optionmenu_img_widget.grid_remove() diff --git a/vrct_gui/ui_managers/Themes/_darkTheme.py b/vrct_gui/ui_managers/Themes/_darkTheme.py index fe3c1aa9..15721fb8 100644 --- a/vrct_gui/ui_managers/Themes/_darkTheme.py +++ b/vrct_gui/ui_managers/Themes/_darkTheme.py @@ -90,6 +90,11 @@ def _darkTheme(base_color): SLS__OPTIONMENU_HOVERED_BG_COLOR = base_color.DARK_875_COLOR, SLS__OPTIONMENU_CLICKED_BG_COLOR = base_color.DARK_900_COLOR, + SLS__DROPDOWN_MENU_WINDOW_BG_COLOR = base_color.DARK_888_COLOR, + SLS__DROPDOWN_MENU_WINDOW_BORDER_COLOR = base_color.DARK_650_COLOR, + SLS__DROPDOWN_MENU_BG_COLOR = base_color.DARK_888_COLOR, + SLS__DROPDOWN_MENU_HOVERED_BG_COLOR = base_color.DARK_825_COLOR, + SLS__DROPDOWN_MENU_CLICKED_BG_COLOR = base_color.DARK_900_COLOR, CONFIG_BUTTON_BG_COLOR = base_color.DARK_850_COLOR, CONFIG_BUTTON_HOVERED_BG_COLOR = base_color.DARK_800_COLOR, diff --git a/vrct_gui/ui_managers/Themes/_lightTheme.py b/vrct_gui/ui_managers/Themes/_lightTheme.py index 0815e602..2261386e 100644 --- a/vrct_gui/ui_managers/Themes/_lightTheme.py +++ b/vrct_gui/ui_managers/Themes/_lightTheme.py @@ -90,6 +90,11 @@ def _lightTheme(base_color): SLS__OPTIONMENU_HOVERED_BG_COLOR = base_color.LIGHT_250_COLOR, SLS__OPTIONMENU_CLICKED_BG_COLOR = base_color.LIGHT_400_COLOR, + SLS__DROPDOWN_MENU_WINDOW_BG_COLOR = base_color.LIGHT_300_COLOR, + SLS__DROPDOWN_MENU_WINDOW_BORDER_COLOR = base_color.LIGHT_700_COLOR, + SLS__DROPDOWN_MENU_BG_COLOR = base_color.LIGHT_300_COLOR, + SLS__DROPDOWN_MENU_HOVERED_BG_COLOR = base_color.LIGHT_200_COLOR, + SLS__DROPDOWN_MENU_CLICKED_BG_COLOR = base_color.LIGHT_400_COLOR, CONFIG_BUTTON_BG_COLOR = base_color.LIGHT_250_COLOR, CONFIG_BUTTON_HOVERED_BG_COLOR = base_color.LIGHT_350_COLOR, diff --git a/vrct_gui/ui_managers/UiScalingManager.py b/vrct_gui/ui_managers/UiScalingManager.py index 8fea6a2c..bbf7326d 100644 --- a/vrct_gui/ui_managers/UiScalingManager.py +++ b/vrct_gui/ui_managers/UiScalingManager.py @@ -141,6 +141,24 @@ class UiScalingManager(): self.main.MINIMIZE_SIDEBAR_BUTTON_ICON_SIZE_Y = self._calculateUiSize(26) + self.main.SLS__SELECTABLE_TRANSLATION_IPADX = self.dupTuple(self._calculateUiSize(10)) + self.main.SLS__SELECTABLE_TRANSLATION_IPADY = self._calculateUiSize(6) + self.main.SLS__SELECTABLE_TRANSLATION_FONT_SIZE = self._calculateUiSize(12) + self.main.SLS__SELECTABLE_TRANSLATION_IMAGE_SIZE = self.dupTuple(self._calculateUiSize(10)) + self.main.SLS__SELECTABLE_TRANSLATION_PADY = self._calculateUiSize(4) + self.main.SLS__SELECTABLE_TRANSLATION_MIN_PADX = self._calculateUiSize(8) + + + self.main.SLS__DROPDOWN_MENU_WINDOW_ADDITIONAL_Y_POS = self._calculateUiSize(4) + self.main.SLS__DROPDOWN_MENU_WINDOW_BORDER_WIDTH = self._calculateUiSize(0, is_allowed_odd=True) + self.main.SLS__DROPDOWN_MENU_SCROLLBAR_IPADX = self.common.SCROLLBAR_IPADX + self.main.SLS__DROPDOWN_MENU_SCROLLBAR_WIDTH = self.common.SCROLLBAR_WIDTH + self.main.SLS__DROPDOWN_MENU_VALUE_IPADX = (self._calculateUiSize(8), 0) + self.main.SLS__DROPDOWN_MENU_VALUE_IPADY = self.dupTuple(self._calculateUiSize(8)) + self.main.SLS__DROPDOWN_MENU_VALUE_PADY = 0 + self.main.SLS__DROPDOWN_MENU_VALUE_FONT_SIZE = self._calculateUiSize(14) + self.main.SLS__DROPDOWN_MENU_VALUE_DEFAULT_MIN_WIDTH = self._calculateUiSize(200) + # Selectable Language Window self.selectable_language_window.TOP_BAR_MIN_HEIGHT = self._calculateUiSize(50) @@ -257,7 +275,6 @@ class UiScalingManager(): self.config_window.SB__OPTIONMENU_IMG_SIZE = (self._calculateUiSize(14), self._calculateUiSize(14)) self.config_window.SB__DROPDOWN_MENU_WINDOW_ADDITIONAL_Y_POS = self._calculateUiSize(4) - self.config_window.SB__DROPDOWN_MENU_WIDTH = self.config_window.SB__OPTIONMENU_MIN_WIDTH self.config_window.SB__DROPDOWN_MENU_WINDOW_BORDER_WIDTH = self._calculateUiSize(1, is_allowed_odd=True) self.config_window.SB__DROPDOWN_MENU_SCROLLBAR_IPADX = self.common.SCROLLBAR_IPADX self.config_window.SB__DROPDOWN_MENU_SCROLLBAR_WIDTH = self.common.SCROLLBAR_WIDTH diff --git a/vrct_gui/ui_utils/ui_utils.py b/vrct_gui/ui_utils/ui_utils.py index 9a8e992b..3e6dcccf 100644 --- a/vrct_gui/ui_utils/ui_utils.py +++ b/vrct_gui/ui_utils/ui_utils.py @@ -168,6 +168,55 @@ def createButtonWithImage(parent_widget, button_image_size, button_ipadxy, butto return button_wrapper +def createLabelButton(parent_widget, label_button_bg_color, label_button_hovered_bg_color, label_button_clicked_bg_color, label_button_ipadx, label_button_ipady, variable, font_family, font_size, text_color, label_button_clicked_command, label_button_position=None, label_button_padx_between_img=0, label_button_min_height=None, label_button_min_width=None): + + label_button_box = CTkFrame(parent_widget, corner_radius=6, fg_color=label_button_bg_color, cursor="hand2") + + label_button_box.grid_rowconfigure(0, weight=1) + if label_button_min_height is not None: + label_button_box.grid_rowconfigure(0, minsize=label_button_min_height) + + label_button_box.grid_columnconfigure(0, weight=1) + if label_button_min_width is not None: + label_button_box.grid_columnconfigure(0, minsize=label_button_min_width) + + label_button_label_wrapper = CTkFrame(label_button_box, corner_radius=0, fg_color=label_button_bg_color) + label_button_label_wrapper.grid(row=0, column=0, padx=label_button_ipadx, pady=label_button_ipady, sticky="ew") + + LABEL_COLUMN=0 + if label_button_position == "center": + label_button_label_wrapper.grid_columnconfigure((0,2), weight=1) + LABEL_COLUMN=1 + + label_button_label_widget = CTkLabel( + label_button_label_wrapper, + textvariable=variable, + height=0, + font=CTkFont(family=font_family, size=font_size, weight="normal"), + text_color=text_color + ) + label_button_label_widget.grid(row=0, column=LABEL_COLUMN, padx=(0, label_button_padx_between_img)) + + + bindEnterAndLeaveColor([label_button_label_wrapper, label_button_box, label_button_label_widget], label_button_hovered_bg_color, label_button_bg_color) + bindButtonPressColor([label_button_label_wrapper, label_button_box, label_button_label_widget], label_button_clicked_bg_color, label_button_hovered_bg_color) + + + + bindButtonReleaseFunction([label_button_label_wrapper, label_button_box, label_button_label_widget], label_button_clicked_command) + + def unbindEventFromWidgets(): + unbindEnterLEaveButtonPressButtonReleaseFunction([label_button_label_wrapper, label_button_box, label_button_label_widget]) + + label_button_box.unbindFunction = unbindEventFromWidgets + + + return (label_button_box, label_button_label_widget) + + + + + 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, optionmenu_clicked_command, optionmenu_position=None, optionmenu_padx_between_img=0, optionmenu_min_height=None, optionmenu_min_width=None, setattr_widget=None, image_widget_attr_name=None): option_menu_box = CTkFrame(parent_widget, corner_radius=6, fg_color=optionmenu_bg_color, cursor="hand2") diff --git a/vrct_gui/vrct_gui.py b/vrct_gui/vrct_gui.py index 7a4970c4..e59b332d 100644 --- a/vrct_gui/vrct_gui.py +++ b/vrct_gui/vrct_gui.py @@ -75,22 +75,22 @@ class VRCT_GUI(CTk): settings=settings.dropdown_menu_window, view_variable=self._view_variable, - window_additional_y_pos=4, - window_border_width=1, - scrollbar_ipadx=(2,2), - scrollbar_width=16, - value_ipadx=(8,0), - value_ipady=(6,6), - value_pady=0, - value_font_size=14, - dropdown_menu_default_min_width=200, + window_additional_y_pos=self.settings.main.uism.SLS__DROPDOWN_MENU_WINDOW_ADDITIONAL_Y_POS, + window_border_width=self.settings.main.uism.SLS__DROPDOWN_MENU_WINDOW_BORDER_WIDTH, + scrollbar_ipadx=self.settings.main.uism.SLS__DROPDOWN_MENU_SCROLLBAR_IPADX, + scrollbar_width=self.settings.main.uism.SLS__DROPDOWN_MENU_SCROLLBAR_WIDTH, + value_ipadx=self.settings.main.uism.SLS__DROPDOWN_MENU_VALUE_IPADX, + value_ipady=self.settings.main.uism.SLS__DROPDOWN_MENU_VALUE_IPADY, + value_pady=self.settings.main.uism.SLS__DROPDOWN_MENU_VALUE_PADY, + value_font_size=self.settings.main.uism.SLS__DROPDOWN_MENU_VALUE_FONT_SIZE, + dropdown_menu_default_min_width=self.settings.main.uism.SLS__DROPDOWN_MENU_VALUE_DEFAULT_MIN_WIDTH, - window_bg_color="#1f2022", - window_border_color="#7f8084", - values_bg_color="#323336", - values_hovered_bg_color="#4b4c4f", - values_clicked_bg_color="#292a2d", - values_text_color=settings.main.ctm.BASIC_TEXT_COLOR, + window_bg_color=self.settings.main.ctm.SLS__DROPDOWN_MENU_WINDOW_BG_COLOR, + window_border_color=self.settings.main.ctm.SLS__DROPDOWN_MENU_WINDOW_BORDER_COLOR, + values_bg_color=self.settings.main.ctm.SLS__DROPDOWN_MENU_BG_COLOR, + values_hovered_bg_color=self.settings.main.ctm.SLS__DROPDOWN_MENU_HOVERED_BG_COLOR, + values_clicked_bg_color=self.settings.main.ctm.SLS__DROPDOWN_MENU_CLICKED_BG_COLOR, + values_text_color=self.settings.main.ctm.BASIC_TEXT_COLOR, ) createMainWindowWidgets(