diff --git a/view.py b/view.py index ccd98abd..12f10cdf 100644 --- a/view.py +++ b/view.py @@ -3,7 +3,7 @@ from tkinter import font as tk_font from languages import selectable_languages from customtkinter import StringVar, IntVar, BooleanVar, END as CTK_END, get_appearance_mode -from vrct_gui.ui_managers import ColorThemeManager, ImageFilenameManager, UiScalingManager +from vrct_gui.ui_managers import ColorThemeManager, ImageFileManager, UiScalingManager from vrct_gui import vrct_gui from config import config @@ -14,10 +14,10 @@ class View(): theme = get_appearance_mode() if config.APPEARANCE_THEME == "System" else config.APPEARANCE_THEME all_ctm = ColorThemeManager(theme) all_uism = UiScalingManager(config.UI_SCALING) - image_filename = ImageFilenameManager(theme) + image_file = ImageFileManager(theme) common_args = { - "image_filename": image_filename, + "image_file": image_file, "FONT_FAMILY": config.FONT_FAMILY, } diff --git a/vrct_gui/_changeMainWindowWidgetsStatus.py b/vrct_gui/_changeMainWindowWidgetsStatus.py index 4fed6db0..5e02a67c 100644 --- a/vrct_gui/_changeMainWindowWidgetsStatus.py +++ b/vrct_gui/_changeMainWindowWidgetsStatus.py @@ -18,15 +18,15 @@ def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, ta widget_label.configure(text_color=settings.ctm.SF__TEXT_DISABLED_COLOR) widget_switch_box.configure(state="disabled", progress_color=settings.ctm.SF__SWITCH_BOX_DISABLE_BG_COLOR) widget_selected_mark.configure(fg_color=settings.ctm.SF__SELECTED_MARK_DISABLE_BG_COLOR) - icon_filename = disabled_icon_name + icon_file = disabled_icon_name elif status == "normal": widget_frame.configure(cursor="hand2") widget_label.configure(text_color=settings.ctm.LABELS_TEXT_COLOR) widget_switch_box.configure(state="normal", progress_color=settings.ctm.SF__SWITCH_BOX_ACTIVE_BG_COLOR) widget_selected_mark.configure(fg_color=settings.ctm.SF__SELECTED_MARK_ACTIVE_BG_COLOR) - icon_filename = icon_name + icon_file = icon_name - image = CTkImage(getImageFileFromUiUtils(icon_filename), size=COMPACT_MODE_ICON_SIZE_TUPLES) + image = CTkImage(icon_file, size=COMPACT_MODE_ICON_SIZE_TUPLES) widget_compact_mode_icon.configure(image=image) @@ -41,8 +41,8 @@ def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, ta widget_switch_box=vrct_gui.translation_switch_box, widget_selected_mark=vrct_gui.translation_selected_mark, widget_compact_mode_icon=vrct_gui.translation_compact_mode_icon, - icon_name=settings.image_filename.TRANSLATION_ICON, - disabled_icon_name=settings.image_filename.TRANSLATION_ICON_DISABLED + icon_name=settings.image_file.TRANSLATION_ICON, + disabled_icon_name=settings.image_file.TRANSLATION_ICON_DISABLED ) case "transcription_send_switch": update_switch_status( @@ -51,8 +51,8 @@ def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, ta widget_switch_box=vrct_gui.transcription_send_switch_box, widget_selected_mark=vrct_gui.transcription_send_selected_mark, widget_compact_mode_icon=vrct_gui.transcription_send_compact_mode_icon, - icon_name=settings.image_filename.MIC_ICON, - disabled_icon_name=settings.image_filename.MIC_ICON_DISABLED + icon_name=settings.image_file.MIC_ICON, + disabled_icon_name=settings.image_file.MIC_ICON_DISABLED ) case "transcription_receive_switch": update_switch_status( @@ -61,8 +61,8 @@ def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, ta widget_switch_box=vrct_gui.transcription_receive_switch_box, widget_selected_mark=vrct_gui.transcription_receive_selected_mark, widget_compact_mode_icon=vrct_gui.transcription_receive_compact_mode_icon, - icon_name=settings.image_filename.HEADPHONES_ICON, - disabled_icon_name=settings.image_filename.HEADPHONES_ICON_DISABLED + icon_name=settings.image_file.HEADPHONES_ICON, + disabled_icon_name=settings.image_file.HEADPHONES_ICON_DISABLED ) case "foreground_switch": update_switch_status( @@ -71,8 +71,8 @@ def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, ta widget_switch_box=vrct_gui.foreground_switch_box, widget_selected_mark=vrct_gui.foreground_selected_mark, widget_compact_mode_icon=vrct_gui.foreground_compact_mode_icon, - icon_name=settings.image_filename.FOREGROUND_ICON, - disabled_icon_name=settings.image_filename.FOREGROUND_ICON_DISABLED + icon_name=settings.image_file.FOREGROUND_ICON, + disabled_icon_name=settings.image_file.FOREGROUND_ICON_DISABLED ) @@ -105,12 +105,12 @@ def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, ta if status == "disabled": vrct_gui.sidebar_config_button_wrapper.configure(cursor="") vrct_gui.sidebar_config_button.configure( - image=CTkImage(getImageFileFromUiUtils(settings.image_filename.CONFIGURATION_ICON_DISABLED)), + image=CTkImage((settings.image_file.CONFIGURATION_ICON_DISABLED)), ) elif status == "normal": vrct_gui.sidebar_config_button_wrapper.configure(cursor="hand2") vrct_gui.sidebar_config_button.configure( - image=CTkImage(getImageFileFromUiUtils(settings.image_filename.CONFIGURATION_ICON)), + image=CTkImage((settings.image_file.CONFIGURATION_ICON)), ) @@ -121,17 +121,17 @@ def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, ta if view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE is True: - image_file = CTkImage(getImageFileFromUiUtils(settings.image_filename.ARROW_LEFT_DISABLED).rotate(180), size=LOGO_SIZE) + image_file = CTkImage((settings.image_file.ARROW_LEFT_DISABLED).rotate(180), size=LOGO_SIZE) else: - image_file = CTkImage(getImageFileFromUiUtils(settings.image_filename.ARROW_LEFT_DISABLED), size=LOGO_SIZE) + image_file = CTkImage((settings.image_file.ARROW_LEFT_DISABLED), size=LOGO_SIZE) vrct_gui.minimize_sidebar_button.configure(image=image_file) elif status == "normal": vrct_gui.minimize_sidebar_button_container.configure(cursor="hand2") if view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE is True: - image_file = CTkImage(getImageFileFromUiUtils(settings.image_filename.ARROW_LEFT).rotate(180), size=LOGO_SIZE) + image_file = CTkImage((settings.image_file.ARROW_LEFT).rotate(180), size=LOGO_SIZE) else: - image_file = CTkImage(getImageFileFromUiUtils(settings.image_filename.ARROW_LEFT), size=LOGO_SIZE) + image_file = CTkImage((settings.image_file.ARROW_LEFT), size=LOGO_SIZE) vrct_gui.minimize_sidebar_button.configure(image=image_file) diff --git a/vrct_gui/config_window/widgets/createConfigWindowTitle.py b/vrct_gui/config_window/widgets/createConfigWindowTitle.py index bbbd9606..e638f61c 100644 --- a/vrct_gui/config_window/widgets/createConfigWindowTitle.py +++ b/vrct_gui/config_window/widgets/createConfigWindowTitle.py @@ -34,6 +34,6 @@ def createConfigWindowTitle(config_window, settings): text=None, height=0, anchor="w", - image=CTkImage(getImageFileFromUiUtils(settings.image_filename.VRCT_LOGO_MARK),size=settings.uism.TOP_BAR_SIDE__CONFIG_LOGO_MARK_SIZE), + image=CTkImage(settings.image_file.VRCT_LOGO_MARK, size=settings.uism.TOP_BAR_SIDE__CONFIG_LOGO_MARK_SIZE), ) config_window.side_menu_config_window_title_logo.place(relx=0.08, rely=0.59, anchor="w") diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py index 3f91fa48..20b43474 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py @@ -185,7 +185,7 @@ class _SettingBoxGenerator(): progressbar_attr_name, passive_button_attr_name, passive_button_command, active_button_attr_name, active_button_command, - button_image_filename, + button_image_file, variable, slider_number_of_steps: Union[int, None] = None, @@ -276,10 +276,10 @@ class _SettingBoxGenerator(): - passive_button_wrapper = self._createPassiveButtonForProgressbarXSlider(setting_box_progressbar_x_slider_frame, BUTTON_PADDING, passive_button_command, button_image_filename) + passive_button_wrapper = self._createPassiveButtonForProgressbarXSlider(setting_box_progressbar_x_slider_frame, BUTTON_PADDING, passive_button_command, button_image_file) setattr(self.config_window, passive_button_attr_name, passive_button_wrapper) - active_button_wrapper = self._createActiveButtonForProgressbarXSlider(setting_box_progressbar_x_slider_frame, BUTTON_PADDING, active_button_command, button_image_filename) + active_button_wrapper = self._createActiveButtonForProgressbarXSlider(setting_box_progressbar_x_slider_frame, BUTTON_PADDING, active_button_command, button_image_file) setattr(self.config_window, active_button_attr_name, active_button_wrapper) passive_button_wrapper.grid() @@ -467,13 +467,13 @@ class _SettingBoxGenerator(): - def _createPassiveButtonForProgressbarXSlider(self, setting_box_progressbar_x_slider_frame, BUTTON_PADDING, button_command, button_image_filename): + def _createPassiveButtonForProgressbarXSlider(self, setting_box_progressbar_x_slider_frame, BUTTON_PADDING, button_command, button_image_file): button_wrapper = createButtonWithImage( parent_widget=setting_box_progressbar_x_slider_frame, button_fg_color=self.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_COLOR, button_enter_color=self.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_HOVERED_COLOR, button_clicked_color=self.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_CLICKED_COLOR, - button_image_filename=button_image_filename, + button_image_file=button_image_file, button_image_size=self.uism.SB__PROGRESSBAR_X_SLIDER__BUTTON_ICON_SIZE, button_ipadxy=self.uism.SB__PROGRESSBAR_X_SLIDER__BUTTON_IPADXY, button_command=button_command, @@ -485,13 +485,13 @@ class _SettingBoxGenerator(): - def _createActiveButtonForProgressbarXSlider(self, setting_box_progressbar_x_slider_frame, BUTTON_PADDING, button_command, button_image_filename): + def _createActiveButtonForProgressbarXSlider(self, setting_box_progressbar_x_slider_frame, BUTTON_PADDING, button_command, button_image_file): button_wrapper = createButtonWithImage( parent_widget=setting_box_progressbar_x_slider_frame, button_fg_color=self.ctm.SB__PROGRESSBAR_X_SLIDER__ACTIVE_BUTTON_COLOR, button_enter_color=self.ctm.SB__PROGRESSBAR_X_SLIDER__ACTIVE_BUTTON_HOVERED_COLOR, button_clicked_color=self.ctm.SB__PROGRESSBAR_X_SLIDER__ACTIVE_BUTTON_CLICKED_COLOR, - button_image_filename=button_image_filename, + button_image_file=button_image_file, button_image_size=self.uism.SB__PROGRESSBAR_X_SLIDER__BUTTON_ICON_SIZE, button_ipadxy=self.uism.SB__PROGRESSBAR_X_SLIDER__BUTTON_IPADXY, button_command=button_command, 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 3a53b3c0..1ca96a8c 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 @@ -1,5 +1,3 @@ -from time import sleep - from utils import callFunctionIfCallable from .._SettingBoxGenerator import _SettingBoxGenerator @@ -13,14 +11,13 @@ def createSettingBox_Mic(setting_box_wrapper, config_window, settings, view_vari def checkbox_input_mic_threshold_check_callback(e, passive_button_wrapper_widget, active_button_wrapper_widget, is_turned_on): - callFunctionIfCallable(config_window.CALLBACK_CHECK_MIC_THRESHOLD, 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() - sleep(1) passive_button_wrapper_widget.grid_remove() active_button_wrapper_widget.grid() @@ -118,7 +115,7 @@ def createSettingBox_Mic(setting_box_wrapper, config_window, settings, view_vari config_window.sb__progressbar_x_slider__active_button_mic_energy_threshold, is_turned_on=False, ), - button_image_filename="mic_icon_white.png" + button_image_file=settings.image_file.MIC_ICON ) config_window.sb__mic_energy_threshold.grid(row=row) row+=1 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 a27a7f5c..911c10f1 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 time import sleep from utils import callFunctionIfCallable @@ -13,14 +12,13 @@ def createSettingBox_Speaker(setting_box_wrapper, config_window, settings, view_ def checkbox_input_speaker_threshold_check_callback(e, passive_button_wrapper_widget, active_button_wrapper_widget, is_turned_on): - callFunctionIfCallable(config_window.CALLBACK_CHECK_SPEAKER_THRESHOLD, 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() - sleep(1) passive_button_wrapper_widget.grid_remove() active_button_wrapper_widget.grid() @@ -99,7 +97,7 @@ def createSettingBox_Speaker(setting_box_wrapper, config_window, settings, view_ config_window.sb__progressbar_x_slider__active_button_speaker_energy_threshold, is_turned_on=False, ), - button_image_filename="headphones_icon_white.png" + button_image_file=settings.image_file.HEADPHONES_ICON ) config_window.sb__speaker_energy_threshold.grid(row=row) row+=1 diff --git a/vrct_gui/main_window/createMainWindowWidgets.py b/vrct_gui/main_window/createMainWindowWidgets.py index 9a33ef0c..d55a66ed 100644 --- a/vrct_gui/main_window/createMainWindowWidgets.py +++ b/vrct_gui/main_window/createMainWindowWidgets.py @@ -48,7 +48,7 @@ def createMainWindowWidgets(vrct_gui, settings, view_variable): button_fg_color=settings.ctm.HELP_AND_INFO_BUTTON_BG_COLOR, button_enter_color=settings.ctm.HELP_AND_INFO_BUTTON_HOVERED_BG_COLOR, button_clicked_color=settings.ctm.HELP_AND_INFO_BUTTON_CLICKED_BG_COLOR, - button_image_filename=settings.image_filename.HELP_ICON, + button_image_file=settings.image_file.HELP_ICON, button_image_size=settings.uism.HELP_AND_INFO_BUTTON_SIZE, button_ipadxy=settings.uism.HELP_AND_INFO_BUTTON_IPADXY, button_command=vrct_gui.openHelpAndInfoWindow, diff --git a/vrct_gui/main_window/widgets/_create_sidebar/createSidebarFeatures.py b/vrct_gui/main_window/widgets/_create_sidebar/createSidebarFeatures.py index aec073a7..eeb373d9 100644 --- a/vrct_gui/main_window/widgets/_create_sidebar/createSidebarFeatures.py +++ b/vrct_gui/main_window/widgets/_create_sidebar/createSidebarFeatures.py @@ -69,7 +69,7 @@ def createSidebarFeatures(settings, main_window, view_variable): - (img, width, height) = openImageKeepAspectRatio(settings.image_filename.VRCT_LOGO, settings.uism.SF__LOGO_MAX_SIZE) + (img, width, height) = openImageKeepAspectRatio(settings.image_file.VRCT_LOGO, settings.uism.SF__LOGO_MAX_SIZE) main_window.sidebar_logo = CTkLabel( main_window.sidebar_bg_container, fg_color=settings.ctm.SIDEBAR_BG_COLOR, @@ -81,7 +81,7 @@ def createSidebarFeatures(settings, main_window, view_variable): # "height-a_s" represents the adjustment in size, and the "pady+a_s/2" indicates a padding increase of 4 pixels to compensate for the reduction. a_s = settings.uism.SF__LOGO_HEIGHT_FOR_ADJUSTMENT - (img, width, height) = openImageKeepAspectRatio(settings.image_filename.VRCT_LOGO_MARK, height-a_s) + (img, width, height) = openImageKeepAspectRatio(settings.image_file.VRCT_LOGO_MARK, height-a_s) main_window.sidebar_compact_mode_logo = CTkLabel( main_window.sidebar_compact_mode_bg_container, fg_color=settings.ctm.SIDEBAR_BG_COLOR, @@ -119,7 +119,7 @@ def createSidebarFeatures(settings, main_window, view_variable): "compact_mode_frame_attr_name": "compact_mode_translation_frame", "selected_mark_attr_name": "translation_selected_mark", "var_label_text": view_variable.VAR_LABEL_TRANSLATION, - "icon_file_name": settings.image_filename.TRANSLATION_ICON, + "icon_file": settings.image_file.TRANSLATION_ICON, }, { "frame_attr_name": "transcription_send_frame", @@ -131,7 +131,7 @@ def createSidebarFeatures(settings, main_window, view_variable): "compact_mode_frame_attr_name": "compact_mode_transcription_send_frame", "selected_mark_attr_name": "transcription_send_selected_mark", "var_label_text": view_variable.VAR_LABEL_TRANSCRIPTION_SEND, - "icon_file_name": settings.image_filename.MIC_ICON, + "icon_file": settings.image_file.MIC_ICON, }, { "frame_attr_name": "transcription_receive_frame", @@ -143,7 +143,7 @@ def createSidebarFeatures(settings, main_window, view_variable): "compact_mode_frame_attr_name": "compact_mode_transcription_receive_frame", "selected_mark_attr_name": "transcription_receive_selected_mark", "var_label_text": view_variable.VAR_LABEL_TRANSCRIPTION_RECEIVE, - "icon_file_name": settings.image_filename.HEADPHONES_ICON, + "icon_file": settings.image_file.HEADPHONES_ICON, }, { "frame_attr_name": "foreground_frame", @@ -155,7 +155,7 @@ def createSidebarFeatures(settings, main_window, view_variable): "compact_mode_frame_attr_name": "compact_mode_foreground_frame", "selected_mark_attr_name": "foreground_selected_mark", "var_label_text": view_variable.VAR_LABEL_FOREGROUND, - "icon_file_name": settings.image_filename.FOREGROUND_ICON, + "icon_file": settings.image_file.FOREGROUND_ICON, }, ] @@ -172,7 +172,7 @@ def createSidebarFeatures(settings, main_window, view_variable): compact_mode_frame_attr_name = sfs["compact_mode_frame_attr_name"] selected_mark_attr_name = sfs["selected_mark_attr_name"] var_label_text = sfs["var_label_text"] - icon_file_name = sfs["icon_file_name"] + icon_file = sfs["icon_file"] frame_widget = CTkFrame(main_window.sidebar_features_container, corner_radius=0, fg_color=settings.ctm.SF__BG_COLOR, cursor="hand2", width=0, height=0) setattr(main_window, frame_attr_name, frame_widget) @@ -234,7 +234,7 @@ def createSidebarFeatures(settings, main_window, view_variable): text=None, height=0, corner_radius=0, - image=CTkImage(getImageFileFromUiUtils(icon_file_name),size=(settings.COMPACT_MODE_ICON_SIZE,settings.COMPACT_MODE_ICON_SIZE)), + image=CTkImage((icon_file),size=(settings.COMPACT_MODE_ICON_SIZE,settings.COMPACT_MODE_ICON_SIZE)), ) setattr(main_window, compact_mode_icon_attr_name, compact_mode_icon_widget) diff --git a/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py b/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py index bdd57585..df698570 100644 --- a/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py +++ b/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py @@ -234,7 +234,7 @@ def createSidebarLanguagesSettings(settings, main_window, view_variable): main_window.sls__arrow_direction_box, text=None, height=0, - image=CTkImage(getImageFileFromUiUtils(settings.image_filename.NARROW_ARROW_DOWN).rotate(180),size=settings.uism.SLS__BOX_ARROWS_IMAGE_SIZE) + image=CTkImage((settings.image_file.NARROW_ARROW_DOWN).rotate(180),size=settings.uism.SLS__BOX_ARROWS_IMAGE_SIZE) ) main_window.sls__both_direction_up.grid(row=0, column=1, pady=0) @@ -253,7 +253,7 @@ def createSidebarLanguagesSettings(settings, main_window, view_variable): main_window.sls__arrow_direction_box, text=None, height=0, - image=CTkImage(getImageFileFromUiUtils(settings.image_filename.NARROW_ARROW_DOWN).rotate(0),size=settings.uism.SLS__BOX_ARROWS_IMAGE_SIZE) + image=CTkImage((settings.image_file.NARROW_ARROW_DOWN).rotate(0),size=settings.uism.SLS__BOX_ARROWS_IMAGE_SIZE) ) main_window.sls__both_direction_label_down.grid(row=0, column=3, pady=0) @@ -296,7 +296,7 @@ def createSidebarLanguagesSettings(settings, main_window, view_variable): main_window.sidebar_config_button_wrapper, text=None, height=0, - image=CTkImage(getImageFileFromUiUtils(settings.image_filename.CONFIGURATION_ICON),size=(settings.COMPACT_MODE_ICON_SIZE,settings.COMPACT_MODE_ICON_SIZE)) + image=CTkImage((settings.image_file.CONFIGURATION_ICON),size=(settings.COMPACT_MODE_ICON_SIZE,settings.COMPACT_MODE_ICON_SIZE)) ) main_window.sidebar_config_button.grid(row=0, column=0, padx=0, pady=settings.uism.SIDEBAR_CONFIG_BUTTON_IPADY) diff --git a/vrct_gui/main_window/widgets/create_minimize_sidebar_button.py b/vrct_gui/main_window/widgets/create_minimize_sidebar_button.py index da06788b..250e2ac4 100644 --- a/vrct_gui/main_window/widgets/create_minimize_sidebar_button.py +++ b/vrct_gui/main_window/widgets/create_minimize_sidebar_button.py @@ -24,16 +24,16 @@ def createMinimizeSidebarButton(settings, main_window, view_variable): text=None, corner_radius=0, height=0, - image=CTkImage(getImageFileFromUiUtils(settings.image_filename.ARROW_LEFT),size=(settings.uism.MINIMIZE_SIDEBAR_BUTTON_ICON_SIZE_X,settings.uism.MINIMIZE_SIDEBAR_BUTTON_ICON_SIZE_Y)) + image=CTkImage((settings.image_file.ARROW_LEFT),size=(settings.uism.MINIMIZE_SIDEBAR_BUTTON_ICON_SIZE_X,settings.uism.MINIMIZE_SIDEBAR_BUTTON_ICON_SIZE_Y)) ) if view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE is True: - image_file = CTkImage(getImageFileFromUiUtils(settings.image_filename.ARROW_LEFT).rotate(180),size=(settings.uism.MINIMIZE_SIDEBAR_BUTTON_ICON_SIZE_X,settings.uism.MINIMIZE_SIDEBAR_BUTTON_ICON_SIZE_Y)) + image_file = CTkImage((settings.image_file.ARROW_LEFT).rotate(180),size=(settings.uism.MINIMIZE_SIDEBAR_BUTTON_ICON_SIZE_X,settings.uism.MINIMIZE_SIDEBAR_BUTTON_ICON_SIZE_Y)) bindButtonReleaseFunction([main_window.minimize_sidebar_button_container, main_window.minimize_sidebar_button], disableCompactMode) else: - image_file = CTkImage(getImageFileFromUiUtils(settings.image_filename.ARROW_LEFT),size=(settings.uism.MINIMIZE_SIDEBAR_BUTTON_ICON_SIZE_X,settings.uism.MINIMIZE_SIDEBAR_BUTTON_ICON_SIZE_Y)) + image_file = CTkImage((settings.image_file.ARROW_LEFT),size=(settings.uism.MINIMIZE_SIDEBAR_BUTTON_ICON_SIZE_X,settings.uism.MINIMIZE_SIDEBAR_BUTTON_ICON_SIZE_Y)) bindButtonReleaseFunction([main_window.minimize_sidebar_button_container, main_window.minimize_sidebar_button], enableCompactMode) main_window.minimize_sidebar_button_container.grid_rowconfigure((0,2), weight=1) diff --git a/vrct_gui/ui_managers/ImageFileManager.py b/vrct_gui/ui_managers/ImageFileManager.py new file mode 100644 index 00000000..62dcc122 --- /dev/null +++ b/vrct_gui/ui_managers/ImageFileManager.py @@ -0,0 +1,57 @@ +from ..ui_utils import getImageFileFromUiUtils + + +class ImageFileManager(): + def __init__(self, theme:str ="Dark"): + if theme == "Dark": + self._createDarkModeImages() + elif theme == "Light": + self._createLightModeImages() + + + def _createDarkModeImages(self): + self.VRCT_LOGO = getImageFileFromUiUtils("vrct_logo_for_dark_mode.png") + self.VRCT_LOGO_MARK = getImageFileFromUiUtils("vrct_logo_mark_white.png") + + self.TRANSLATION_ICON = getImageFileFromUiUtils("translation_icon_white.png") + self.TRANSLATION_ICON_DISABLED = getImageFileFromUiUtils("translation_icon_disabled.png") + self.MIC_ICON = getImageFileFromUiUtils("mic_icon_white.png") + self.MIC_ICON_DISABLED = getImageFileFromUiUtils("mic_icon_disabled.png") + self.HEADPHONES_ICON = getImageFileFromUiUtils("headphones_icon_white.png") + self.HEADPHONES_ICON_DISABLED = getImageFileFromUiUtils("headphones_icon_disabled.png") + self.FOREGROUND_ICON = getImageFileFromUiUtils("foreground_icon_white.png") + self.FOREGROUND_ICON_DISABLED = getImageFileFromUiUtils("foreground_icon_disabled.png") + + self.NARROW_ARROW_DOWN = getImageFileFromUiUtils("narrow_arrow_down.png") + + self.CONFIGURATION_ICON = getImageFileFromUiUtils("configuration_icon_white.png") + self.CONFIGURATION_ICON_DISABLED = getImageFileFromUiUtils("configuration_icon_disabled.png") + + self.ARROW_LEFT = getImageFileFromUiUtils("arrow_left_white.png") + self.ARROW_LEFT_DISABLED = getImageFileFromUiUtils("arrow_left_disabled.png") + + self.HELP_ICON = getImageFileFromUiUtils("help_icon_white.png") + + def _createLightModeImages(self): + self.VRCT_LOGO = getImageFileFromUiUtils("vrct_logo_for_light_mode.png") + self.VRCT_LOGO_MARK = getImageFileFromUiUtils("vrct_logo_mark_black.png") + + + self.TRANSLATION_ICON = getImageFileFromUiUtils("translation_icon_white.png") + self.TRANSLATION_ICON_DISABLED = getImageFileFromUiUtils("translation_icon_disabled.png") + self.MIC_ICON = getImageFileFromUiUtils("mic_icon_white.png") + self.MIC_ICON_DISABLED = getImageFileFromUiUtils("mic_icon_disabled.png") + self.HEADPHONES_ICON = getImageFileFromUiUtils("headphones_icon_white.png") + self.HEADPHONES_ICON_DISABLED = getImageFileFromUiUtils("headphones_icon_disabled.png") + self.FOREGROUND_ICON = getImageFileFromUiUtils("foreground_icon_white.png") + self.FOREGROUND_ICON_DISABLED = getImageFileFromUiUtils("foreground_icon_disabled.png") + + self.NARROW_ARROW_DOWN = getImageFileFromUiUtils("narrow_arrow_down.png") + + self.CONFIGURATION_ICON = getImageFileFromUiUtils("configuration_icon_white.png") + self.CONFIGURATION_ICON_DISABLED = getImageFileFromUiUtils("configuration_icon_disabled.png") + + self.ARROW_LEFT = getImageFileFromUiUtils("arrow_left_white.png") + self.ARROW_LEFT_DISABLED = getImageFileFromUiUtils("arrow_left_disabled.png") + + self.HELP_ICON = getImageFileFromUiUtils("help_icon_white.png") \ No newline at end of file diff --git a/vrct_gui/ui_managers/ImageFilenameManager.py b/vrct_gui/ui_managers/ImageFilenameManager.py deleted file mode 100644 index 82573f37..00000000 --- a/vrct_gui/ui_managers/ImageFilenameManager.py +++ /dev/null @@ -1,54 +0,0 @@ -class ImageFilenameManager(): - def __init__(self, theme:str ="Dark"): - if theme == "Dark": - return self._createDarkModeImages() - elif theme == "Light": - return self._createLightModeImages() - - - def _createDarkModeImages(self): - self.VRCT_LOGO = "vrct_logo_for_dark_mode.png" - self.VRCT_LOGO_MARK = "vrct_logo_mark_white.png" - - self.TRANSLATION_ICON = "translation_icon_white.png" - self.TRANSLATION_ICON_DISABLED = "translation_icon_disabled.png" - self.MIC_ICON = "mic_icon_white.png" - self.MIC_ICON_DISABLED = "mic_icon_disabled.png" - self.HEADPHONES_ICON = "headphones_icon_white.png" - self.HEADPHONES_ICON_DISABLED = "headphones_icon_disabled.png" - self.FOREGROUND_ICON = "foreground_icon_white.png" - self.FOREGROUND_ICON_DISABLED = "foreground_icon_disabled.png" - - self.NARROW_ARROW_DOWN = "narrow_arrow_down.png" - - self.CONFIGURATION_ICON = "configuration_icon_white.png" - self.CONFIGURATION_ICON_DISABLED = "configuration_icon_disabled.png" - - self.ARROW_LEFT = "arrow_left_white.png" - self.ARROW_LEFT_DISABLED = "arrow_left_disabled.png" - - self.HELP_ICON = "help_icon_white.png" - - def _createLightModeImages(self): - self.VRCT_LOGO = "vrct_logo_for_light_mode.png" - self.VRCT_LOGO_MARK = "vrct_logo_mark_black.png" - - - self.TRANSLATION_ICON = "translation_icon_white.png" - self.TRANSLATION_ICON_DISABLED = "translation_icon_disabled.png" - self.MIC_ICON = "mic_icon_white.png" - self.MIC_ICON_DISABLED = "mic_icon_disabled.png" - self.HEADPHONES_ICON = "headphones_icon_white.png" - self.HEADPHONES_ICON_DISABLED = "headphones_icon_disabled.png" - self.FOREGROUND_ICON = "foreground_icon_white.png" - self.FOREGROUND_ICON_DISABLED = "foreground_icon_disabled.png" - - self.NARROW_ARROW_DOWN = "narrow_arrow_down.png" - - self.CONFIGURATION_ICON = "configuration_icon_white.png" - self.CONFIGURATION_ICON_DISABLED = "configuration_icon_disabled.png" - - self.ARROW_LEFT = "arrow_left_white.png" - self.ARROW_LEFT_DISABLED = "arrow_left_disabled.png" - - self.HELP_ICON = "help_icon_white.png" \ No newline at end of file diff --git a/vrct_gui/ui_managers/UiScalingManager.py b/vrct_gui/ui_managers/UiScalingManager.py index e7d244b2..0eb5c5d4 100644 --- a/vrct_gui/ui_managers/UiScalingManager.py +++ b/vrct_gui/ui_managers/UiScalingManager.py @@ -8,7 +8,7 @@ class UiScalingManager(): self.main = SimpleNamespace() self.config_window = SimpleNamespace() - return self._calculatedUiSizes() + self._calculatedUiSizes() diff --git a/vrct_gui/ui_managers/__init__.py b/vrct_gui/ui_managers/__init__.py index f6a5abc0..f0dd1edb 100644 --- a/vrct_gui/ui_managers/__init__.py +++ b/vrct_gui/ui_managers/__init__.py @@ -1,3 +1,3 @@ from .ColorThemeManager import ColorThemeManager -from .ImageFilenameManager import ImageFilenameManager +from .ImageFileManager import ImageFileManager from .UiScalingManager import UiScalingManager \ No newline at end of file diff --git a/vrct_gui/ui_utils/ui_utils.py b/vrct_gui/ui_utils/ui_utils.py index d714fc3c..272fbef1 100644 --- a/vrct_gui/ui_utils/ui_utils.py +++ b/vrct_gui/ui_utils/ui_utils.py @@ -12,11 +12,10 @@ def getImageFileFromUiUtils(file_name): img = Image_open(os_path.join(os_path.dirname(os_path.dirname(os_path.dirname(__file__))), "img", file_name)) return img -def openImageKeepAspectRatio(file_name, desired_width): - img = getImageFileFromUiUtils(file_name) - wpercent = (desired_width/float(img.size[0])) - hsize = int((float(img.size[1])*float(wpercent))) - img = img.resize((desired_width,hsize), LANCZOS) +def openImageKeepAspectRatio(image_file, desired_width): + wpercent = (desired_width/float(image_file.size[0])) + hsize = int((float(image_file.size[1])*float(wpercent))) + img = image_file.resize((desired_width,hsize), LANCZOS) return (img, desired_width, hsize) def retag(tag, *args): @@ -121,14 +120,14 @@ def switchTabsColor(target_widget, tab_buttons, active_bg_color, active_text_col -def createButtonWithImage(parent_widget, button_fg_color, button_enter_color, button_clicked_color, button_image_filename, button_image_size, button_ipadxy, button_command, corner_radius: int = 0 ,shape: str = "normal"): +def createButtonWithImage(parent_widget, button_fg_color, button_enter_color, button_clicked_color, button_image_file, button_image_size, button_ipadxy, button_command, corner_radius: int = 0 ,shape: str = "normal"): button_wrapper = CTkFrame(parent_widget, corner_radius=corner_radius, fg_color=button_fg_color, height=0, width=0, cursor="hand2") button_widget = CTkLabel( button_wrapper, text=None, height=0, - image=CTkImage(getImageFileFromUiUtils(button_image_filename),size=(button_image_size,button_image_size)), + image=CTkImage((button_image_file),size=(button_image_size,button_image_size)), ) button_widget.grid(row=0, column=0, padx=button_ipadxy, pady=button_ipadxy) diff --git a/vrct_gui/vrct_gui.py b/vrct_gui/vrct_gui.py index 8275f04a..c3e6afde 100644 --- a/vrct_gui/vrct_gui.py +++ b/vrct_gui/vrct_gui.py @@ -4,7 +4,7 @@ from customtkinter import CTk # from window_help_and_info import ToplevelWindowInformation -# from .ui_managers import ColorThemeManager, ImageFilenameManager, UiScalingManager +# from .ui_managers import ColorThemeManager, ImageFileManager, UiScalingManager from ._changeMainWindowWidgetsStatus import _changeMainWindowWidgetsStatus from ._printToTextbox import _printToTextbox