From 13d4a84e7f730b3a80a22ddab377ee30bea07e82 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Wed, 30 Aug 2023 15:13:33 +0900 Subject: [PATCH 1/4] =?UTF-8?q?add=20view.py:=20main.py=E3=81=8B=E3=82=89U?= =?UTF-8?q?I=E3=81=AE=E5=88=9D=E6=9C=9F=E8=A8=AD=E5=AE=9A=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=82=92view.py=E7=A7=BB=E5=8B=95=E3=80=82=E3=81=9D?= =?UTF-8?q?=E3=81=AE=E4=BB=96=E4=B8=80=E9=83=A8=E9=96=A2=E6=95=B0=E5=90=8D?= =?UTF-8?q?=E3=81=AE=E5=A4=89=E6=9B=B4=E3=81=AA=E3=81=A9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 58 +++++++------------ view.py | 43 ++++++++++++++ vrct_gui/config_window/ConfigWindow.py | 2 - .../createSideMenuAndSettingsBoxContainers.py | 4 +- .../main_window/widgets/create_sidebar.py | 10 +--- .../main_window/widgets/create_textbox.py | 4 +- vrct_gui/ui_utils/__init__.py | 3 +- vrct_gui/ui_utils/ui_utils.py | 2 +- vrct_gui/vrct_gui.py | 10 ++++ 9 files changed, 82 insertions(+), 54 deletions(-) create mode 100644 view.py diff --git a/main.py b/main.py index cfd6c49d..1d84ce3e 100644 --- a/main.py +++ b/main.py @@ -1,10 +1,10 @@ from threading import Thread import customtkinter -from customtkinter import StringVar from vrct_gui import vrct_gui from config import config from model import model -from vrct_gui.ui_utils import setDefaultActiveTab + +from view import viewInitializer # func transcription send message def sendMicMessage(message): @@ -111,14 +111,6 @@ def messageBoxPressKeyAny(e): entry_message_box.insert("end", e.char) return "break" -def foregroundOffForcefully(e): - if config.ENABLE_FOREGROUND: - vrct_gui.attributes("-topmost", False) - -def foregroundOnForcefully(e): - if config.ENABLE_FOREGROUND: - vrct_gui.attributes("-topmost", True) - # func select languages def setYourLanguageAndCountry(select): languages = config.SELECTED_TAB_YOUR_LANGUAGES @@ -314,36 +306,28 @@ model.checkOSCStarted() model.checkSoftwareUpdated() # set UI and callback -vrct_gui.CALLBACK_TOGGLE_TRANSLATION = callbackToggleTranslation -vrct_gui.CALLBACK_TOGGLE_TRANSCRIPTION_SEND = callbackToggleTranscriptionSend -vrct_gui.CALLBACK_TOGGLE_TRANSCRIPTION_RECEIVE = callbackToggleTranscriptionReceive -vrct_gui.CALLBACK_TOGGLE_FOREGROUND = callbackToggleForeground +viewInitializer( + sidebar_features={ + "callback_toggle_translation": callbackToggleTranslation, + "callback_toggle_transcription_send": callbackToggleTranscriptionSend, + "callback_toggle_transcription_receive": callbackToggleTranscriptionReceive, + "callback_toggle_foreground": callbackToggleForeground, + }, -entry_message_box = getattr(vrct_gui, "entry_message_box") -entry_message_box.bind("", messageBoxPressKeyEnter) -entry_message_box.bind("", messageBoxPressKeyAny) -entry_message_box.bind("", foregroundOffForcefully) -entry_message_box.bind("", foregroundOnForcefully) + language_presets={ + "callback_your_language": setYourLanguageAndCountry, + "callback_target_language": setTargetLanguageAndCountry, + "values": model.getListLanguageAndCountry(), -sqls__optionmenu_your_language = getattr(vrct_gui, "sqls__optionmenu_your_language") -sqls__optionmenu_your_language.configure(values=model.getListLanguageAndCountry()) -sqls__optionmenu_your_language.configure(command=setYourLanguageAndCountry) -sqls__optionmenu_your_language.configure(variable=StringVar(value=config.SELECTED_TAB_YOUR_LANGUAGES[config.SELECTED_TAB_NO])) + "callback_selected_tab_no_1": callbackSelectedTabNo1, + "callback_selected_tab_no_2": callbackSelectedTabNo2, + "callback_selected_tab_no_3": callbackSelectedTabNo3, + }, -sqls__optionmenu_target_language = getattr(vrct_gui, "sqls__optionmenu_target_language") -sqls__optionmenu_target_language.configure(values=model.getListLanguageAndCountry()) -sqls__optionmenu_target_language.configure(command=setTargetLanguageAndCountry) -sqls__optionmenu_target_language.configure(variable=StringVar(value=config.SELECTED_TAB_TARGET_LANGUAGES[config.SELECTED_TAB_NO])) - -vrct_gui.CALLBACK_SELECTED_TAB_NO_1 = callbackSelectedTabNo1 -vrct_gui.CALLBACK_SELECTED_TAB_NO_2 = callbackSelectedTabNo2 -vrct_gui.CALLBACK_SELECTED_TAB_NO_3 = callbackSelectedTabNo3 - -vrct_gui.current_active_preset_tab = getattr(vrct_gui, f"sqls__presets_button_{config.SELECTED_TAB_NO}") -setDefaultActiveTab( - active_tab_widget=vrct_gui.current_active_preset_tab, - active_bg_color=vrct_gui.settings.main.ctm.SQLS__PRESETS_TAB_BG_ACTIVE_COLOR, - active_text_color=vrct_gui.settings.main.ctm.SQLS__PRESETS_TAB_ACTIVE_TEXT_COLOR + entry_message_box={ + "bind_Return": messageBoxPressKeyEnter, + "bind_Any_KeyPress": messageBoxPressKeyAny, + }, ) if __name__ == "__main__": diff --git a/view.py b/view.py new file mode 100644 index 00000000..e902a09b --- /dev/null +++ b/view.py @@ -0,0 +1,43 @@ +from customtkinter import StringVar +from vrct_gui import vrct_gui + +from config import config + +def viewInitializer(sidebar_features, language_presets, entry_message_box): + + vrct_gui.CALLBACK_TOGGLE_TRANSLATION = sidebar_features["callback_toggle_translation"], + vrct_gui.CALLBACK_TOGGLE_TRANSCRIPTION_SEND = sidebar_features["callback_toggle_transcription_send"], + vrct_gui.CALLBACK_TOGGLE_TRANSCRIPTION_RECEIVE = sidebar_features["callback_toggle_transcription_receive"], + vrct_gui.CALLBACK_TOGGLE_FOREGROUND = sidebar_features["callback_toggle_foreground"], + + + vrct_gui.sqls__optionmenu_your_language.configure(values=language_presets["values"]) + vrct_gui.sqls__optionmenu_your_language.configure(variable=StringVar(value=config.SELECTED_TAB_YOUR_LANGUAGES[config.SELECTED_TAB_NO])) + vrct_gui.sqls__optionmenu_target_language.configure(values=language_presets["values"]) + vrct_gui.sqls__optionmenu_target_language.configure(variable=StringVar(value=config.SELECTED_TAB_TARGET_LANGUAGES[config.SELECTED_TAB_NO])) + + vrct_gui.CALLBACK_SELECTED_TAB_NO_1 = language_presets["callback_selected_tab_no_1"] + vrct_gui.CALLBACK_SELECTED_TAB_NO_2 = language_presets["callback_selected_tab_no_2"] + vrct_gui.CALLBACK_SELECTED_TAB_NO_3 = language_presets["callback_selected_tab_no_3"] + vrct_gui.setDefaultActiveLanguagePresetTab(tab_no=config.SELECTED_TAB_NO) + + + def foregroundOffForcefully(e): + if config.ENABLE_FOREGROUND: + vrct_gui.attributes("-topmost", False) + + def foregroundOnForcefully(e): + if config.ENABLE_FOREGROUND: + vrct_gui.attributes("-topmost", True) + + + entry_message_box = getattr(vrct_gui, "entry_message_box") + entry_message_box.bind("", lambda: entry_message_box["bind_Return"]) + entry_message_box.bind("", lambda: entry_message_box["bind_Any_KeyPress"]) + entry_message_box.bind("", foregroundOffForcefully) + entry_message_box.bind("", foregroundOnForcefully) + + + + + diff --git a/vrct_gui/config_window/ConfigWindow.py b/vrct_gui/config_window/ConfigWindow.py index f0f27f5b..3e95aa62 100644 --- a/vrct_gui/config_window/ConfigWindow.py +++ b/vrct_gui/config_window/ConfigWindow.py @@ -2,8 +2,6 @@ from .widgets import createConfigWindowTitle, createSettingBoxTitle, createSideM from customtkinter import CTkToplevel -from ..ui_utils import setDefaultActiveTab - from config import config class ConfigWindow(CTkToplevel): diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/createSideMenuAndSettingsBoxContainers.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/createSideMenuAndSettingsBoxContainers.py index 08ef24a7..2c47507f 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/createSideMenuAndSettingsBoxContainers.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/createSideMenuAndSettingsBoxContainers.py @@ -1,6 +1,6 @@ from customtkinter import CTkFrame, CTkScrollableFrame -from ....ui_utils import setDefaultActiveTab +from ....ui_utils import _setDefaultActiveTab from ._addConfigSideMenuItem import _addConfigSideMenuItem from ._createSettingBoxContainer import _createSettingBoxContainer @@ -138,7 +138,7 @@ def createSideMenuAndSettingsBoxContainers(config_window, settings): # Set default active side menu tab config_window.main_current_active_config_title.configure(text=sm_and_sbc_setting["text"]) config_window.current_active_side_menu_tab = getattr(config_window, sm_and_sbc_setting["side_menu_tab_attr_name"]) - setDefaultActiveTab( + _setDefaultActiveTab( active_tab_widget=config_window.current_active_side_menu_tab, active_bg_color=settings.ctm.SIDE_MENU_LABELS_BG_COLOR, active_text_color=settings.ctm.SIDE_MENU_LABELS_SELECTED_TEXT_COLOR diff --git a/vrct_gui/main_window/widgets/create_sidebar.py b/vrct_gui/main_window/widgets/create_sidebar.py index 0a24336b..86e6b75f 100644 --- a/vrct_gui/main_window/widgets/create_sidebar.py +++ b/vrct_gui/main_window/widgets/create_sidebar.py @@ -1,6 +1,6 @@ from customtkinter import CTkOptionMenu, CTkFont, CTkFrame, CTkLabel, CTkSwitch, CTkImage, StringVar -from ...ui_utils import getImageFileFromUiUtils, openImageKeepAspectRatio, retag, getLatestHeight, bindEnterAndLeaveColor, bindButtonPressColor, bindEnterAndLeaveFunction, bindButtonReleaseFunction, bindButtonPressAndReleaseFunction, setDefaultActiveTab, bindButtonFunctionAndColor, switchActiveTabAndPassiveTab, switchTabsColor +from ...ui_utils import getImageFileFromUiUtils, openImageKeepAspectRatio, retag, getLatestHeight, bindEnterAndLeaveColor, bindButtonPressColor, bindEnterAndLeaveFunction, bindButtonReleaseFunction, bindButtonPressAndReleaseFunction, bindButtonFunctionAndColor, switchActiveTabAndPassiveTab, switchTabsColor from time import sleep @@ -512,14 +512,6 @@ def createSidebar(settings, main_window): column+=1 - # Set default active preset tab - # main_window.current_active_preset_tab = getattr(main_window, "sqls__presets_button_1") - # setDefaultActiveTab( - # active_tab_widget=main_window.current_active_preset_tab, - # active_bg_color=settings.ctm.SQLS__PRESETS_TAB_BG_ACTIVE_COLOR, - # active_text_color=settings.ctm.SQLS__PRESETS_TAB_ACTIVE_TEXT_COLOR - # ) - # Quick Language settings BOX main_window.sqls__box_frame = CTkFrame(main_window.sqls__container, corner_radius=0, fg_color=settings.ctm.SQLS__BG_COLOR, width=0, height=0) diff --git a/vrct_gui/main_window/widgets/create_textbox.py b/vrct_gui/main_window/widgets/create_textbox.py index 1bc4a05b..c2d6f813 100644 --- a/vrct_gui/main_window/widgets/create_textbox.py +++ b/vrct_gui/main_window/widgets/create_textbox.py @@ -1,6 +1,6 @@ from customtkinter import CTkFont, CTkFrame, CTkLabel, CTkTextbox -from ...ui_utils import getLatestWidth, getLongestText, bindEnterAndLeaveColor, bindButtonPressColor, bindButtonReleaseFunction, setDefaultActiveTab, switchActiveTabAndPassiveTab, switchTabsColor +from ...ui_utils import getLatestWidth, getLongestText, bindEnterAndLeaveColor, bindButtonPressColor, bindButtonReleaseFunction, _setDefaultActiveTab, switchActiveTabAndPassiveTab, switchTabsColor def createTextbox(settings, main_window): @@ -167,7 +167,7 @@ def createTextbox(settings, main_window): # Set default active textbox tab main_window.current_active_textbox_tab = getattr(main_window, "textbox_tab_all") - setDefaultActiveTab( + _setDefaultActiveTab( active_tab_widget=main_window.current_active_textbox_tab, active_bg_color=settings.ctm.TEXTBOX_TAB_BG_ACTIVE_COLOR, active_text_color=settings.ctm.TEXTBOX_TAB_TEXT_ACTIVE_COLOR diff --git a/vrct_gui/ui_utils/__init__.py b/vrct_gui/ui_utils/__init__.py index bc2a1337..e501aebe 100644 --- a/vrct_gui/ui_utils/__init__.py +++ b/vrct_gui/ui_utils/__init__.py @@ -1 +1,2 @@ -from .ui_utils import * \ No newline at end of file +from .ui_utils import * +from .ui_utils import _setDefaultActiveTab \ 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 eb45ea3d..d714fc3c 100644 --- a/vrct_gui/ui_utils/ui_utils.py +++ b/vrct_gui/ui_utils/ui_utils.py @@ -83,7 +83,7 @@ def unbindEventFromActiveTabWidget(active_tab_widget): active_tab_widget.unbind(event_name) active_tab_widget.children["!ctklabel"].unbind(event_name) -def setDefaultActiveTab(active_tab_widget, active_bg_color, active_text_color): +def _setDefaultActiveTab(active_tab_widget, active_bg_color, active_text_color): active_tab_widget.configure(fg_color=active_bg_color, cursor="") active_tab_widget.children["!ctklabel"].configure(fg_color=active_bg_color, text_color=active_text_color) unbindEventFromActiveTabWidget(active_tab_widget) diff --git a/vrct_gui/vrct_gui.py b/vrct_gui/vrct_gui.py index 29fb5bc2..dad8a8a6 100644 --- a/vrct_gui/vrct_gui.py +++ b/vrct_gui/vrct_gui.py @@ -10,6 +10,7 @@ from ._printToTextbox import _printToTextbox from .main_window import createMainWindowWidgets from .config_window import ConfigWindow +from .ui_utils import _setDefaultActiveTab from config import config @@ -104,5 +105,14 @@ class VRCT_GUI(CTk): tags=tags, ) + def setDefaultActiveLanguagePresetTab(self, tab_no:str): + vrct_gui.current_active_preset_tab = getattr(self, f"sqls__presets_button_{tab_no}") + _setDefaultActiveTab( + active_tab_widget=vrct_gui.current_active_preset_tab, + active_bg_color=vrct_gui.settings.main.ctm.SQLS__PRESETS_TAB_BG_ACTIVE_COLOR, + active_text_color=vrct_gui.settings.main.ctm.SQLS__PRESETS_TAB_ACTIVE_TEXT_COLOR + ) + + vrct_gui = VRCT_GUI() \ No newline at end of file From 36dde7f0b30afc0af1e3c4c756fe73e2baeecb13 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Wed, 30 Aug 2023 19:54:40 +0900 Subject: [PATCH 2/4] =?UTF-8?q?main.py=E3=81=8B=E3=82=89view.py=E3=81=AB?= =?UTF-8?q?=E3=81=84=E3=81=8F=E3=81=A4=E3=81=8B=E9=96=A2=E6=95=B0=E7=A7=BB?= =?UTF-8?q?=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 82 ++++++++++++++-------------------------------- view.py | 100 ++++++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 103 insertions(+), 79 deletions(-) diff --git a/main.py b/main.py index 1d84ce3e..c38a2161 100644 --- a/main.py +++ b/main.py @@ -3,8 +3,8 @@ import customtkinter from vrct_gui import vrct_gui from config import config from model import model - -from view import viewInitializer +from customtkinter import StringVar +from view import view # func transcription send message def sendMicMessage(message): @@ -35,11 +35,11 @@ def sendMicMessage(message): def startTranscriptionSendMessage(): model.startMicTranscript(sendMicMessage) - vrct_gui.changeMainWindowWidgetsStatus("normal", "All") + view.setMainWindowAllWidgetsStatusToNormal() def stopTranscriptionSendMessage(): model.stopMicTranscript() - vrct_gui.changeMainWindowWidgetsStatus("normal", "All") + view.setMainWindowAllWidgetsStatusToNormal() # func transcription receive message def receiveSpeakerMessage(message): @@ -61,11 +61,11 @@ def receiveSpeakerMessage(message): def startTranscriptionReceiveMessage(): model.startSpeakerTranscript(receiveSpeakerMessage) - vrct_gui.changeMainWindowWidgetsStatus("normal", "All") + view.setMainWindowAllWidgetsStatusToNormal() def stopTranscriptionReceiveMessage(): model.stopSpeakerTranscript() - vrct_gui.changeMainWindowWidgetsStatus("normal", "All") + view.setMainWindowAllWidgetsStatusToNormal() # func message box def sendChatMessage(message): @@ -99,8 +99,7 @@ def sendChatMessage(message): def messageBoxPressKeyEnter(e): model.oscStopSendTyping() - entry_message_box = getattr(vrct_gui, "entry_message_box") - message = entry_message_box.get() + message = view.getTextFromMessageBox() sendChatMessage(message) def messageBoxPressKeyAny(e): @@ -179,36 +178,6 @@ def callbackSelectedTabNo3(): config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE) # func print textbox -def logTranslationStatusChange(): - textbox_all = getattr(vrct_gui, "textbox_all") - textbox_system = getattr(vrct_gui, "textbox_system") - if config.ENABLE_TRANSLATION is True: - vrct_gui.printToTextbox(textbox_all, "翻訳機能をONにしました", "", "INFO") - vrct_gui.printToTextbox(textbox_system, "翻訳機能をONにしました", "", "INFO") - else: - vrct_gui.printToTextbox(textbox_all, "翻訳機能をOFFにしました", "", "INFO") - vrct_gui.printToTextbox(textbox_system, "翻訳機能をOFFにしました", "", "INFO") - -def logTranscriptionSendStatusChange(): - textbox_all = getattr(vrct_gui, "textbox_all") - textbox_system = getattr(vrct_gui, "textbox_system") - if config.ENABLE_TRANSCRIPTION_SEND is True: - vrct_gui.printToTextbox(textbox_all, "Voice2chatbox機能をONにしました", "", "INFO") - vrct_gui.printToTextbox(textbox_system, "Voice2chatbox機能をONにしました", "", "INFO") - else: - vrct_gui.printToTextbox(textbox_all, "Voice2chatbox機能をOFFにしました", "", "INFO") - vrct_gui.printToTextbox(textbox_system, "Voice2chatbox機能をOFFにしました", "", "INFO") - -def logTranscriptionReceiveStatusChange(): - textbox_all = getattr(vrct_gui, "textbox_all") - textbox_system = getattr(vrct_gui, "textbox_system") - if config.ENABLE_TRANSCRIPTION_RECEIVE is True: - vrct_gui.printToTextbox(textbox_all, "Speaker2chatbox機能をONにしました", "", "INFO") - vrct_gui.printToTextbox(textbox_system, "Speaker2chatbox機能をONにしました", "", "INFO") - else: - vrct_gui.printToTextbox(textbox_all, "Speaker2chatbox機能をOFFにしました", "", "INFO") - vrct_gui.printToTextbox(textbox_system, "Speaker2chatbox機能をOFFにしました", "", "INFO") - def logSendMessage(message, translate): textbox_all = getattr(vrct_gui, "textbox_all") textbox_sent = getattr(vrct_gui, "textbox_sent") @@ -239,54 +208,51 @@ def logOSCError(): vrct_gui.printToTextbox(textbox_all, "OSC is not enabled, please enable OSC and rejoin", "", "INFO") vrct_gui.printToTextbox(textbox_system, "OSC is not enabled, please enable OSC and rejoin", "", "INFO") -def logForegroundStatusChange(): - textbox_all = getattr(vrct_gui, "textbox_all") - textbox_system = getattr(vrct_gui, "textbox_system") - if config.ENABLE_FOREGROUND is True: - vrct_gui.printToTextbox(textbox_all, "Start foreground", "", "INFO") - vrct_gui.printToTextbox(textbox_system, "Start foreground", "", "INFO") - else: - vrct_gui.printToTextbox(textbox_all, "Stop foreground", "", "INFO") - vrct_gui.printToTextbox(textbox_system, "Stop foreground", "", "INFO") # command func def callbackToggleTranslation(): - config.ENABLE_TRANSLATION = getattr(vrct_gui, "translation_switch_box").get() - logTranslationStatusChange() + config.ENABLE_TRANSLATION = view.getTranslationButtonStatus() + if config.ENABLE_TRANSLATION is True: + view.printToTextbox_enableTranslation() + else: + view.printToTextbox_disableTranslation() def callbackToggleTranscriptionSend(): - vrct_gui.changeMainWindowWidgetsStatus("disabled", "All") - config.ENABLE_TRANSCRIPTION_SEND = getattr(vrct_gui, "transcription_send_switch_box").get() + view.setMainWindowAllWidgetsStatusToDisabled() + config.ENABLE_TRANSCRIPTION_SEND = view.getTranscriptionSendButtonStatus() if config.ENABLE_TRANSCRIPTION_SEND is True: + view.printToTextbox_enableTranscriptionSend() th_startTranscriptionSendMessage = Thread(target=startTranscriptionSendMessage) th_startTranscriptionSendMessage.daemon = True th_startTranscriptionSendMessage.start() else: + view.printToTextbox_disableTranscriptionSend() th_stopTranscriptionSendMessage = Thread(target=stopTranscriptionSendMessage) th_stopTranscriptionSendMessage.daemon = True th_stopTranscriptionSendMessage.start() - logTranscriptionSendStatusChange() def callbackToggleTranscriptionReceive(): - vrct_gui.changeMainWindowWidgetsStatus("disabled", "All") - config.ENABLE_TRANSCRIPTION_RECEIVE = getattr(vrct_gui, "transcription_receive_switch_box").get() + view.setMainWindowAllWidgetsStatusToDisabled() + config.ENABLE_TRANSCRIPTION_RECEIVE = view.getTranscriptionReceiveButtonStatus() if config.ENABLE_TRANSCRIPTION_RECEIVE is True: + view.printToTextbox_enableTranscriptionReceive() th_startTranscriptionReceiveMessage = Thread(target=startTranscriptionReceiveMessage) th_startTranscriptionReceiveMessage.daemon = True th_startTranscriptionReceiveMessage.start() else: + view.printToTextbox_disableTranscriptionReceive() th_stopTranscriptionReceiveMessage = Thread(target=stopTranscriptionReceiveMessage) th_stopTranscriptionReceiveMessage.daemon = True th_stopTranscriptionReceiveMessage.start() - logTranscriptionReceiveStatusChange() def callbackToggleForeground(): - config.ENABLE_FOREGROUND = getattr(vrct_gui, "foreground_switch_box").get() + config.ENABLE_FOREGROUND = view.getForegroundButtonStatus() if config.ENABLE_FOREGROUND is True: + view.printToTextbox_enableForeground() vrct_gui.attributes("-topmost", True) else: + view.printToTextbox_disableForeground() vrct_gui.attributes("-topmost", False) - logForegroundStatusChange() # create GUI vrct_gui.createGUI() @@ -306,7 +272,7 @@ model.checkOSCStarted() model.checkSoftwareUpdated() # set UI and callback -viewInitializer( +view.initializer( sidebar_features={ "callback_toggle_translation": callbackToggleTranslation, "callback_toggle_transcription_send": callbackToggleTranscriptionSend, diff --git a/view.py b/view.py index e902a09b..e472f0d5 100644 --- a/view.py +++ b/view.py @@ -3,41 +3,99 @@ from vrct_gui import vrct_gui from config import config -def viewInitializer(sidebar_features, language_presets, entry_message_box): - - vrct_gui.CALLBACK_TOGGLE_TRANSLATION = sidebar_features["callback_toggle_translation"], - vrct_gui.CALLBACK_TOGGLE_TRANSCRIPTION_SEND = sidebar_features["callback_toggle_transcription_send"], - vrct_gui.CALLBACK_TOGGLE_TRANSCRIPTION_RECEIVE = sidebar_features["callback_toggle_transcription_receive"], - vrct_gui.CALLBACK_TOGGLE_FOREGROUND = sidebar_features["callback_toggle_foreground"], +class view(): + def __init__(self): + pass - vrct_gui.sqls__optionmenu_your_language.configure(values=language_presets["values"]) - vrct_gui.sqls__optionmenu_your_language.configure(variable=StringVar(value=config.SELECTED_TAB_YOUR_LANGUAGES[config.SELECTED_TAB_NO])) - vrct_gui.sqls__optionmenu_target_language.configure(values=language_presets["values"]) - vrct_gui.sqls__optionmenu_target_language.configure(variable=StringVar(value=config.SELECTED_TAB_TARGET_LANGUAGES[config.SELECTED_TAB_NO])) + def initializer(self, sidebar_features, language_presets, entry_message_box): - vrct_gui.CALLBACK_SELECTED_TAB_NO_1 = language_presets["callback_selected_tab_no_1"] - vrct_gui.CALLBACK_SELECTED_TAB_NO_2 = language_presets["callback_selected_tab_no_2"] - vrct_gui.CALLBACK_SELECTED_TAB_NO_3 = language_presets["callback_selected_tab_no_3"] - vrct_gui.setDefaultActiveLanguagePresetTab(tab_no=config.SELECTED_TAB_NO) + vrct_gui.CALLBACK_TOGGLE_TRANSLATION = sidebar_features["callback_toggle_translation"] + vrct_gui.CALLBACK_TOGGLE_TRANSCRIPTION_SEND = sidebar_features["callback_toggle_transcription_send"] + vrct_gui.CALLBACK_TOGGLE_TRANSCRIPTION_RECEIVE = sidebar_features["callback_toggle_transcription_receive"] + vrct_gui.CALLBACK_TOGGLE_FOREGROUND = sidebar_features["callback_toggle_foreground"] - def foregroundOffForcefully(e): + vrct_gui.sqls__optionmenu_your_language.configure(values=language_presets["values"]) + vrct_gui.sqls__optionmenu_your_language.configure(command=language_presets["callback_your_language"]) + vrct_gui.sqls__optionmenu_your_language.configure(variable=StringVar(value=config.SELECTED_TAB_YOUR_LANGUAGES[config.SELECTED_TAB_NO])) + vrct_gui.sqls__optionmenu_target_language.configure(values=language_presets["values"]) + vrct_gui.sqls__optionmenu_target_language.configure(command=language_presets["callback_target_language"]) + vrct_gui.sqls__optionmenu_target_language.configure(variable=StringVar(value=config.SELECTED_TAB_TARGET_LANGUAGES[config.SELECTED_TAB_NO])) + + vrct_gui.CALLBACK_SELECTED_TAB_NO_1 = language_presets["callback_selected_tab_no_1"] + vrct_gui.CALLBACK_SELECTED_TAB_NO_2 = language_presets["callback_selected_tab_no_2"] + vrct_gui.CALLBACK_SELECTED_TAB_NO_3 = language_presets["callback_selected_tab_no_3"] + vrct_gui.setDefaultActiveLanguagePresetTab(tab_no=config.SELECTED_TAB_NO) + + + entry_message_box = getattr(vrct_gui, "entry_message_box") + entry_message_box.bind("", lambda: entry_message_box["bind_Return"]) + entry_message_box.bind("", lambda: entry_message_box["bind_Any_KeyPress"]) + entry_message_box.bind("", self._foregroundOffForcefully) + entry_message_box.bind("", self._foregroundOnForcefully) + + + + def setMainWindowAllWidgetsStatusToNormal(self): + vrct_gui.changeMainWindowWidgetsStatus("normal", "All") + + def setMainWindowAllWidgetsStatusToDisabled(self): + vrct_gui.changeMainWindowWidgetsStatus("disabled", "All") + + + + def _foregroundOffForcefully(self, _e): if config.ENABLE_FOREGROUND: vrct_gui.attributes("-topmost", False) - def foregroundOnForcefully(e): + def _foregroundOnForcefully(self, _e): if config.ENABLE_FOREGROUND: vrct_gui.attributes("-topmost", True) - entry_message_box = getattr(vrct_gui, "entry_message_box") - entry_message_box.bind("", lambda: entry_message_box["bind_Return"]) - entry_message_box.bind("", lambda: entry_message_box["bind_Any_KeyPress"]) - entry_message_box.bind("", foregroundOffForcefully) - entry_message_box.bind("", foregroundOnForcefully) + def getTranslationButtonStatus(self): + return vrct_gui.translation_switch_box.get() + def getTranscriptionSendButtonStatus(self): + return vrct_gui.transcription_send_switch_box.get() + def getTranscriptionReceiveButtonStatus(self): + return vrct_gui.transcription_receive_switch_box.get() + def getForegroundButtonStatus(self): + return vrct_gui.foreground_switch_box.get() + def printToTextbox_enableTranslation(self): + self._printToTextbox_Info("翻訳機能をONにしました") + def printToTextbox_disableTranslation(self): + self._printToTextbox_Info("翻訳機能をOFFにしました") + + def printToTextbox_enableTranscriptionSend(self): + self._printToTextbox_Info("Voice2chatbox機能をONにしました") + def printToTextbox_disableTranscriptionSend(self): + self._printToTextbox_Info("Voice2chatbox機能をOFFにしました") + + def printToTextbox_enableTranscriptionReceive(self): + self._printToTextbox_Info("Speaker2chatbox機能をONにしました") + def printToTextbox_disableTranscriptionReceive(self): + self._printToTextbox_Info("Speaker2chatbox機能をOFFにしました") + + def printToTextbox_enableForeground(self): + self._printToTextbox_Info("Start foreground") + def printToTextbox_disableForeground(self): + self._printToTextbox_Info("Stop foreground") + + + def _printToTextbox_Info(self, info_message): + vrct_gui.printToTextbox(vrct_gui.textbox_all, info_message, "", "INFO") + vrct_gui.printToTextbox(vrct_gui.textbox_system, info_message, "", "INFO") + pass + + + + def getTextFromMessageBox(self): + return vrct_gui.entry_message_box.get() + +view = view() \ No newline at end of file From fde7ea6a75631052a1870e50387b1ce3bc5a3089 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Thu, 31 Aug 2023 00:19:19 +0900 Subject: [PATCH 3/4] =?UTF-8?q?main.py=E3=81=8B=E3=82=89view.py=E3=81=AB?= =?UTF-8?q?=E3=81=84=E3=81=8F=E3=81=A4=E3=81=8B=E9=96=A2=E6=95=B0=E7=A7=BB?= =?UTF-8?q?=E5=8B=95=20=E7=B6=9A=E3=81=8D(messageBoxPressKeyAny=E3=81=AF?= =?UTF-8?q?=E5=88=A5=E3=81=AE=E5=A0=B4=E6=89=80=E3=81=AB=E7=A7=BB=E5=8B=95?= =?UTF-8?q?=E3=81=AB=E3=81=AA=E3=82=8B=E3=81=AE=E3=81=A7=E5=88=A5=E3=81=AE?= =?UTF-8?q?=E3=82=B3=E3=83=9F=E3=83=83=E3=83=88=E3=81=AB=E3=80=82=E3=81=9D?= =?UTF-8?q?=E3=82=8C=E4=BB=A5=E5=A4=96=E3=81=AF=E5=AE=8C=E4=BA=86)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 85 +++++++++++++++++++-------------------------------------- view.py | 74 +++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 90 insertions(+), 69 deletions(-) diff --git a/main.py b/main.py index c38a2161..27d81c3a 100644 --- a/main.py +++ b/main.py @@ -11,12 +11,12 @@ def sendMicMessage(message): if len(message) > 0: translation = "" if model.checkKeywords(message): - logDetectWordFilter(message) + view.printToTextbox_DetectedByWordFilter(detected_message=message) return elif config.ENABLE_TRANSLATION is False: pass elif model.getTranslatorStatus() is False: - logAuthenticationError() + view.printToTextbox_AuthenticationError() else: translation = model.getInputTranslate(message) @@ -29,9 +29,9 @@ def sendMicMessage(message): osc_message = message model.oscSendMessage(osc_message) else: - logOSCError() + view.printToTextbox_OSCError() - logSendMessage(message, translation) + view.printToTextbox_SentMessage(message, translation) def startTranscriptionSendMessage(): model.startMicTranscript(sendMicMessage) @@ -48,7 +48,7 @@ def receiveSpeakerMessage(message): if config.ENABLE_TRANSLATION is False: pass elif model.getTranslatorStatus() is False: - logAuthenticationError() + view.printToTextbox_AuthenticationError() else: translation = model.getOutputTranslate(message) @@ -57,7 +57,7 @@ def receiveSpeakerMessage(message): xsoverlay_message = config.MESSAGE_FORMAT.replace("[message]", message) xsoverlay_message = xsoverlay_message.replace("[translation]", translation) model.notificationXSOverlay(xsoverlay_message) - logReceiveMessage(message, translation) + view.printToTextbox_ReceivedMessage(message, translation) def startTranscriptionReceiveMessage(): model.startSpeakerTranscript(receiveSpeakerMessage) @@ -74,7 +74,7 @@ def sendChatMessage(message): if config.ENABLE_TRANSLATION is False: pass elif model.getTranslatorStatus() is False: - logAuthenticationError() + view.printToTextbox_AuthenticationError() else: translation = model.getInputTranslate(message) @@ -87,15 +87,14 @@ def sendChatMessage(message): osc_message = message model.oscSendMessage(osc_message) else: - logOSCError() + view.printToTextbox_OSCError() # update textbox message log - logSendMessage(message, translation) + view.printToTextbox_SentMessage(message, translation) # delete message in entry message box if config.ENABLE_AUTO_CLEAR_CHATBOX is True: - entry_message_box = getattr(vrct_gui, "entry_message_box") - entry_message_box.delete(0, customtkinter.END) + view.clearMessageBox() def messageBoxPressKeyEnter(e): model.oscStopSendTyping() @@ -131,8 +130,7 @@ def setTargetLanguageAndCountry(select): def callbackSelectedTabNo1(): config.SELECTED_TAB_NO = "1" - vrct_gui.YOUR_LANGUAGE = config.SELECTED_TAB_YOUR_LANGUAGES[config.SELECTED_TAB_NO] - vrct_gui.TARGET_LANGUAGE = config.SELECTED_TAB_TARGET_LANGUAGES[config.SELECTED_TAB_NO] + view.updateGuiVariableByPresetTabNo(config.SELECTED_TAB_NO) languages = config.SELECTED_TAB_YOUR_LANGUAGES select = languages[config.SELECTED_TAB_NO] language, country = model.getLanguageAndCountry(select) @@ -147,8 +145,7 @@ def callbackSelectedTabNo1(): def callbackSelectedTabNo2(): config.SELECTED_TAB_NO = "2" - vrct_gui.YOUR_LANGUAGE = config.SELECTED_TAB_YOUR_LANGUAGES[config.SELECTED_TAB_NO] - vrct_gui.TARGET_LANGUAGE = config.SELECTED_TAB_TARGET_LANGUAGES[config.SELECTED_TAB_NO] + view.updateGuiVariableByPresetTabNo(config.SELECTED_TAB_NO) languages = config.SELECTED_TAB_YOUR_LANGUAGES select = languages[config.SELECTED_TAB_NO] language, country = model.getLanguageAndCountry(select) @@ -163,8 +160,7 @@ def callbackSelectedTabNo2(): def callbackSelectedTabNo3(): config.SELECTED_TAB_NO = "3" - vrct_gui.YOUR_LANGUAGE = config.SELECTED_TAB_YOUR_LANGUAGES[config.SELECTED_TAB_NO] - vrct_gui.TARGET_LANGUAGE = config.SELECTED_TAB_TARGET_LANGUAGES[config.SELECTED_TAB_NO] + view.updateGuiVariableByPresetTabNo(config.SELECTED_TAB_NO) languages = config.SELECTED_TAB_YOUR_LANGUAGES select = languages[config.SELECTED_TAB_NO] language, country = model.getLanguageAndCountry(select) @@ -177,37 +173,6 @@ def callbackSelectedTabNo3(): config.TARGET_COUNTRY = country config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE) -# func print textbox -def logSendMessage(message, translate): - textbox_all = getattr(vrct_gui, "textbox_all") - textbox_sent = getattr(vrct_gui, "textbox_sent") - vrct_gui.printToTextbox(textbox_all, message, translate, "SEND") - vrct_gui.printToTextbox(textbox_sent, message, translate, "SEND") - -def logReceiveMessage(message, translate): - textbox_all = getattr(vrct_gui, "textbox_all") - textbox_sent = getattr(vrct_gui, "textbox_received") - vrct_gui.printToTextbox(textbox_all, message, translate, "RECEIVE") - vrct_gui.printToTextbox(textbox_sent, message, translate, "RECEIVE") - -def logDetectWordFilter(message): - textbox_all = getattr(vrct_gui, "textbox_all") - textbox_system = getattr(vrct_gui, "textbox_system") - vrct_gui.printToTextbox(textbox_all, f"Detect WordFilter :{message}", "", "INFO") - vrct_gui.printToTextbox(textbox_system, f"Detect WordFilter :{message}", "", "INFO") - -def logAuthenticationError(): - textbox_all = getattr(vrct_gui, "textbox_all") - textbox_system = getattr(vrct_gui, "textbox_system") - vrct_gui.printToTextbox(textbox_all, "Auth Key or language setting is incorrect", "", "INFO") - vrct_gui.printToTextbox(textbox_system, "Auth Key or language setting is incorrect", "", "INFO") - -def logOSCError(): - textbox_all = getattr(vrct_gui, "textbox_all") - textbox_system = getattr(vrct_gui, "textbox_system") - vrct_gui.printToTextbox(textbox_all, "OSC is not enabled, please enable OSC and rejoin", "", "INFO") - vrct_gui.printToTextbox(textbox_system, "OSC is not enabled, please enable OSC and rejoin", "", "INFO") - # command func def callbackToggleTranslation(): @@ -249,18 +214,18 @@ def callbackToggleForeground(): config.ENABLE_FOREGROUND = view.getForegroundButtonStatus() if config.ENABLE_FOREGROUND is True: view.printToTextbox_enableForeground() - vrct_gui.attributes("-topmost", True) + view.foregroundOn() else: view.printToTextbox_disableForeground() - vrct_gui.attributes("-topmost", False) + view.foregroundOff() # create GUI -vrct_gui.createGUI() +view.createGUI() # init config if model.authenticationTranslator() is False: # error update Auth key - logAuthenticationError() + view.printToTextbox_AuthenticationError() # set word filter model.addKeywords() @@ -290,11 +255,17 @@ view.initializer( "callback_selected_tab_no_3": callbackSelectedTabNo3, }, - entry_message_box={ - "bind_Return": messageBoxPressKeyEnter, - "bind_Any_KeyPress": messageBoxPressKeyAny, - }, + # 辞書型で関数を渡しても上手く行かず、仕方なくタプルで渡してる。 + # 本当はコメントアウト(以下とview.py内33,34行目)しているようにできたらいいけど、 + # _tkinter.TclError: unknown option "-bind_Any_KeyPress"みたいにエラーがでる。 + entry_message_box=None, + # entry_message_box={ + # "bind_Return": messageBoxPressKeyEnter, + # "bind_Any_KeyPress": messageBoxPressKeyAny, + # }, + entry_message_box_bind_Return=messageBoxPressKeyEnter, + entry_message_box_bind_Any_KeyPress=messageBoxPressKeyAny, ) if __name__ == "__main__": - vrct_gui.startMainLoop() \ No newline at end of file + view.startMainLoop() \ No newline at end of file diff --git a/view.py b/view.py index e472f0d5..0f7c2590 100644 --- a/view.py +++ b/view.py @@ -1,14 +1,14 @@ -from customtkinter import StringVar +from customtkinter import StringVar, END as CTK_END from vrct_gui import vrct_gui from config import config -class view(): +class View(): def __init__(self): pass - def initializer(self, sidebar_features, language_presets, entry_message_box): + def initializer(self, sidebar_features, language_presets, entry_message_box, entry_message_box_bind_Return, entry_message_box_bind_Any_KeyPress): vrct_gui.CALLBACK_TOGGLE_TRANSLATION = sidebar_features["callback_toggle_translation"] vrct_gui.CALLBACK_TOGGLE_TRANSCRIPTION_SEND = sidebar_features["callback_toggle_transcription_send"] @@ -30,8 +30,11 @@ class view(): entry_message_box = getattr(vrct_gui, "entry_message_box") - entry_message_box.bind("", lambda: entry_message_box["bind_Return"]) - entry_message_box.bind("", lambda: entry_message_box["bind_Any_KeyPress"]) + # entry_message_box.bind("", lambda e: entry_message_box["bind_Return"](e)) + # entry_message_box.bind("", lambda e: entry_message_box["bind_Any_KeyPress"](e)) + entry_message_box.bind("", entry_message_box_bind_Return) + entry_message_box.bind("", entry_message_box_bind_Any_KeyPress) + entry_message_box.bind("", self._foregroundOffForcefully) entry_message_box.bind("", self._foregroundOnForcefully) @@ -45,15 +48,25 @@ class view(): - def _foregroundOffForcefully(self, _e): - if config.ENABLE_FOREGROUND: - vrct_gui.attributes("-topmost", False) - def _foregroundOnForcefully(self, _e): if config.ENABLE_FOREGROUND: - vrct_gui.attributes("-topmost", True) + self.foregroundOn() + + def _foregroundOffForcefully(self, _e): + if config.ENABLE_FOREGROUND: + self.foregroundOff() + def foregroundOn(self): + vrct_gui.attributes("-topmost", True) + + def foregroundOff(self): + vrct_gui.attributes("-topmost", False) + + + def updateGuiVariableByPresetTabNo(self, tab_no:str): + vrct_gui.YOUR_LANGUAGE = config.SELECTED_TAB_YOUR_LANGUAGES[tab_no] + vrct_gui.TARGET_LANGUAGE = config.SELECTED_TAB_TARGET_LANGUAGES[tab_no] @@ -88,14 +101,51 @@ class view(): self._printToTextbox_Info("Stop foreground") + def printToTextbox_AuthenticationError(self): + self._printToTextbox_Info("Auth Key or language setting is incorrect") + + def printToTextbox_OSCError(self): + self._printToTextbox_Info("OSC is not enabled, please enable OSC and rejoin") + + def printToTextbox_DetectedByWordFilter(self, detected_message): + self._printToTextbox_Info(f"Detect WordFilter :{detected_message}") + + def _printToTextbox_Info(self, info_message): vrct_gui.printToTextbox(vrct_gui.textbox_all, info_message, "", "INFO") vrct_gui.printToTextbox(vrct_gui.textbox_system, info_message, "", "INFO") - pass + def printToTextbox_SentMessage(self, original_message, translated_message): + self._printToTextbox_Sent(original_message, translated_message) + + def _printToTextbox_Sent(self, original_message, translated_message): + vrct_gui.printToTextbox(vrct_gui.textbox_all, original_message, translated_message, "SEND") + vrct_gui.printToTextbox(vrct_gui.textbox_sent, original_message, translated_message, "SEND") + + + def printToTextbox_ReceivedMessage(self, original_message, translated_message): + self._printToTextbox_Received(original_message, translated_message) + + def _printToTextbox_Received(self, original_message, translated_message): + vrct_gui.printToTextbox(vrct_gui.textbox_all, original_message, translated_message, "RECEIVE") + vrct_gui.printToTextbox(vrct_gui.textbox_received, original_message, translated_message, "RECEIVE") + + def getTextFromMessageBox(self): return vrct_gui.entry_message_box.get() -view = view() \ No newline at end of file + def clearMessageBox(self): + vrct_gui.entry_message_box.delete(0, CTK_END) + + + + + def createGUI(self): + vrct_gui.createGUI() + + def startMainLoop(self): + vrct_gui.startMainLoop() + +view = View() \ No newline at end of file From be5a0e386fbc5b761ae7ab49ae082497d3e18e57 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Thu, 31 Aug 2023 00:43:10 +0900 Subject: [PATCH 4/4] =?UTF-8?q?view.py=E3=81=B8=E3=81=AE=E5=88=86=E9=9B=A2?= =?UTF-8?q?=E5=AE=8C=E4=BA=86(messageBoxPressKeyAny=E3=82=92gui=E5=86=85?= =?UTF-8?q?=E9=83=A8=E3=81=AB=E7=A7=BB=E5=8B=95=E3=80=81=E4=BD=BF=E3=82=8F?= =?UTF-8?q?=E3=81=AA=E3=81=8F=E3=81=AA=E3=81=A3=E3=81=9Fconfig.py=E3=81=AE?= =?UTF-8?q?BREAK=5FKEYSYM=5FLIST=E3=81=AF=E4=B8=80=E6=97=A6=E3=82=B3?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=88=E3=82=A2=E3=82=A6=E3=83=88)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 14 +++++++------- main.py | 8 -------- .../widgets/create_entry_message_box.py | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/config.py b/config.py index 9d8d2ae0..e6199231 100644 --- a/config.py +++ b/config.py @@ -400,9 +400,9 @@ class Config: def GITHUB_URL(self): return self._GITHUB_URL - @property - def BREAK_KEYSYM_LIST(self): - return self._BREAK_KEYSYM_LIST + # @property + # def BREAK_KEYSYM_LIST(self): + # return self._BREAK_KEYSYM_LIST @property def MAX_MIC_ENERGY_THRESHOLD(self): @@ -487,10 +487,10 @@ class Config: self._ENABLE_OSC = False self._UPDATE_FLAG = False self._GITHUB_URL = "https://api.github.com/repos/misyaguziya/VRCT/releases/latest" - self._BREAK_KEYSYM_LIST = [ - "Delete", "Select", "Up", "Down", "Next", "End", "Print", - "Prior","Insert","Home", "Left", "Clear", "Right", "Linefeed" - ] + # self._BREAK_KEYSYM_LIST = [ + # "Delete", "Select", "Up", "Down", "Next", "End", "Print", + # "Prior","Insert","Home", "Left", "Clear", "Right", "Linefeed" + # ] self._MAX_MIC_ENERGY_THRESHOLD = 2000 self._MAX_SPEAKER_ENERGY_THRESHOLD = 4000 self._SELECTED_TAB_NO = "1" diff --git a/main.py b/main.py index 27d81c3a..d1a39236 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,6 @@ from threading import Thread -import customtkinter -from vrct_gui import vrct_gui from config import config from model import model -from customtkinter import StringVar from view import view # func transcription send message @@ -103,11 +100,6 @@ def messageBoxPressKeyEnter(e): def messageBoxPressKeyAny(e): model.oscStartSendTyping() - entry_message_box = getattr(vrct_gui, "entry_message_box") - if e.keysym != "??": - if len(e.char) != 0 and e.keysym in config.BREAK_KEYSYM_LIST: - entry_message_box.insert("end", e.char) - return "break" # func select languages def setYourLanguageAndCountry(select): diff --git a/vrct_gui/main_window/widgets/create_entry_message_box.py b/vrct_gui/main_window/widgets/create_entry_message_box.py index 61dfe593..7bdfb491 100644 --- a/vrct_gui/main_window/widgets/create_entry_message_box.py +++ b/vrct_gui/main_window/widgets/create_entry_message_box.py @@ -19,3 +19,17 @@ def createEntryMessageBox(settings, main_window): ) main_window.entry_message_box.grid(row=0, column=0, padx=settings.uism.TEXTBOX_ENTRY_PADX, pady=settings.uism.TEXTBOX_ENTRY_PADY, sticky="nsew") main_window.entry_message_box._entry.grid(padx=settings.uism.TEXTBOX_ENTRY_IPADX, pady=settings.uism.TEXTBOX_ENTRY_IPADY) + + + def messageBoxAnyKeyPress(e): + BREAK_KEYSYM_LIST = [ + "Delete", "Select", "Up", "Down", "Next", "End", "Print", + "Prior","Insert","Home", "Left", "Clear", "Right", "Linefeed" + ] + if e.keysym != "??": + if len(e.char) != 0 and e.keysym in BREAK_KEYSYM_LIST: + main_window.entry_message_box.insert("end", e.char) + return "break" + + main_window.entry_message_box.bind("", messageBoxAnyKeyPress) +