From a1b53dc2b098184022ecb120385a0be544d3aa0b Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Fri, 19 Jan 2024 01:27:41 +0900 Subject: [PATCH] =?UTF-8?q?[WIP/TEST]=20Controller=20:=20CTranslate2?= =?UTF-8?q?=E3=81=AE=E3=83=A2=E3=83=87=E3=83=AB=E5=A4=89=E6=9B=B4=E6=99=82?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller.py | 10 ++++++---- view.py | 13 ++++++++++++- vrct_gui/_CreateDropdownMenuWindow.py | 6 ++++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/controller.py b/controller.py index d65d010d..a01fc008 100644 --- a/controller.py +++ b/controller.py @@ -491,8 +491,8 @@ def callbackSetUseTranslationFeature(value): if model.checkCTranslatorCTranslate2ModelWeight(): model.changeTranslatorCTranslate2Model() else: - view.useTranslationFeatureProcess("Disable") - # CTranslate2 weight is not downloaded + view.showRestartButtonIfRequired() + view.useTranslationFeatureProcess("Restart") else: view.useTranslationFeatureProcess("Disable") @@ -502,9 +502,11 @@ def callbackSetCtranslate2WeightType(value): view.updateSelectedCtranslate2WeightType(config.WEIGHT_TYPE) if model.checkCTranslatorCTranslate2ModelWeight(): model.changeTranslatorCTranslate2Model() + view.showRestartButtonIfRequired() + view.useTranslationFeatureProcess("Normal") else: - view.useTranslationFeatureProcess("Disable") - # CTranslate2 weight is not downloaded + view.showRestartButtonIfRequired() + view.useTranslationFeatureProcess("Restart") def callbackSetDeeplAuthkey(value): print("callbackSetDeeplAuthkey", str(value)) diff --git a/view.py b/view.py index 52fb174c..02acb490 100644 --- a/view.py +++ b/view.py @@ -28,6 +28,8 @@ class View(): ui_scaling=config.UI_SCALING, font_family=config.FONT_FAMILY, ui_language=config.UI_LANGUAGE, + use_translation_feature=config.USE_TRANSLATION_FEATURE, + ctranslate2_weight_type=config.WEIGHT_TYPE, ) if config.ENABLE_SPEAKER2CHATBOX is False: @@ -891,6 +893,13 @@ class View(): vrct_gui.sls__box_translation_optionmenu_wrapper.grid_remove() vrct_gui.config_window.after(200, vrct_gui.config_window.lift) + elif state == "Restart": + view.setLatestCTranslate2WeightType() + view.setTranslationSwitchStatus("disabled", to_lock_state=True) + vrct_gui.sls__box_translation_optionmenu_wrapper.grid() + vrct_gui.config_window.after(200, vrct_gui.config_window.lift) + + # Open Webpage Functions def openWebPage_Booth(self): self.openWebPage(config.BOOTH_URL) @@ -984,7 +993,9 @@ class View(): self.restart_required_configs_pre_data.appearance_theme == config.APPEARANCE_THEME and self.restart_required_configs_pre_data.ui_scaling == config.UI_SCALING and self.restart_required_configs_pre_data.font_family == config.FONT_FAMILY and - self.restart_required_configs_pre_data.ui_language == config.UI_LANGUAGE + self.restart_required_configs_pre_data.ui_language == config.UI_LANGUAGE and + self.restart_required_configs_pre_data.use_translation_feature == config.USE_TRANSLATION_FEATURE and + self.restart_required_configs_pre_data.ctranslate2_weight_type == config.WEIGHT_TYPE ) if locale is None: diff --git a/vrct_gui/_CreateDropdownMenuWindow.py b/vrct_gui/_CreateDropdownMenuWindow.py index 5ca598e0..7bb233cb 100644 --- a/vrct_gui/_CreateDropdownMenuWindow.py +++ b/vrct_gui/_CreateDropdownMenuWindow.py @@ -326,9 +326,11 @@ class _CreateDropdownMenuWindow(CTkToplevel): def _withdraw(self, e=None): self.withdraw() - self.attach_widget.winfo_toplevel().unbind("", self.BIND_CONFIGURE_FUNC_ID) + if self.BIND_CONFIGURE_FUNC_ID in self.attach_widget.winfo_toplevel().bind(): + self.attach_widget.winfo_toplevel().unbind("", self.BIND_CONFIGURE_FUNC_ID) self.attach_widget.unbind("", self.BIND_UNMAP_FUNC_ID) - self.attach_widget.winfo_toplevel().unbind("", self.BIND_BUTTON_1_FUNC_ID) + if self.BIND_BUTTON_1_FUNC_ID in self.attach_widget.winfo_toplevel().bind(): + self.attach_widget.winfo_toplevel().unbind("", self.BIND_BUTTON_1_FUNC_ID) self.hide = True