Merge branch 'ui_ctranslate2' into develop
This commit is contained in:
@@ -487,10 +487,9 @@ def callbackSetUseTranslationFeature(value):
|
|||||||
print("callbackSetUseTranslationFeature", value)
|
print("callbackSetUseTranslationFeature", value)
|
||||||
config.USE_TRANSLATION_FEATURE = value
|
config.USE_TRANSLATION_FEATURE = value
|
||||||
if config.USE_TRANSLATION_FEATURE is True:
|
if config.USE_TRANSLATION_FEATURE is True:
|
||||||
view.setLatestCTranslate2WeightType()
|
view.useTranslationFeatureProcess("Normal")
|
||||||
view.openCtranslate2WeightTypeWidget()
|
|
||||||
else:
|
else:
|
||||||
view.closeCtranslate2WeightTypeWidget()
|
view.useTranslationFeatureProcess("Disable")
|
||||||
|
|
||||||
def callbackSetCtranslate2WeightType(value):
|
def callbackSetCtranslate2WeightType(value):
|
||||||
print("callbackSetCtranslate2WeightType", value)
|
print("callbackSetCtranslate2WeightType", value)
|
||||||
|
|||||||
27
view.py
27
view.py
@@ -650,9 +650,9 @@ class View():
|
|||||||
self.setMainWindowMessageBoxRatio(config.MESSAGE_BOX_RATIO)
|
self.setMainWindowMessageBoxRatio(config.MESSAGE_BOX_RATIO)
|
||||||
|
|
||||||
if config.USE_TRANSLATION_FEATURE is True:
|
if config.USE_TRANSLATION_FEATURE is True:
|
||||||
self.openCtranslate2WeightTypeWidget()
|
self.useTranslationFeatureProcess("Normal")
|
||||||
else:
|
else:
|
||||||
self.closeCtranslate2WeightTypeWidget()
|
self.useTranslationFeatureProcess("Disable")
|
||||||
|
|
||||||
if config.CHOICE_MIC_HOST == "NoHost":
|
if config.CHOICE_MIC_HOST == "NoHost":
|
||||||
self.view_variable.VAR_MIC_HOST.set("No Mic Host Detected")
|
self.view_variable.VAR_MIC_HOST.set("No Mic Host Detected")
|
||||||
@@ -878,6 +878,20 @@ class View():
|
|||||||
config._SELECTABLE_CTRANSLATE2_WEIGHT_TYPE_DICT["Large"]: i18n.t("config_window.ctranslate2_weight_type.large", capacity="1.2GB"),
|
config._SELECTABLE_CTRANSLATE2_WEIGHT_TYPE_DICT["Large"]: i18n.t("config_window.ctranslate2_weight_type.large", capacity="1.2GB"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def useTranslationFeatureProcess(self, state:str):
|
||||||
|
if state == "Normal":
|
||||||
|
self.setLatestCTranslate2WeightType()
|
||||||
|
self.openCtranslate2WeightTypeWidget()
|
||||||
|
self.setTranslationSwitchStatus("normal", release_locked_state=True)
|
||||||
|
vrct_gui.sls__box_translation_optionmenu_wrapper.grid()
|
||||||
|
vrct_gui.config_window.after(200, vrct_gui.config_window.lift)
|
||||||
|
|
||||||
|
elif state == "Disable":
|
||||||
|
view.closeCtranslate2WeightTypeWidget()
|
||||||
|
view.setTranslationSwitchStatus("disabled", to_lock_state=True)
|
||||||
|
vrct_gui.sls__box_translation_optionmenu_wrapper.grid_remove()
|
||||||
|
vrct_gui.config_window.after(200, vrct_gui.config_window.lift)
|
||||||
|
|
||||||
# Open Webpage Functions
|
# Open Webpage Functions
|
||||||
def openWebPage_Booth(self):
|
def openWebPage_Booth(self):
|
||||||
self.openWebPage(config.BOOTH_URL)
|
self.openWebPage(config.BOOTH_URL)
|
||||||
@@ -916,6 +930,9 @@ class View():
|
|||||||
def setMainWindowAllWidgetsStatusToDisabled():
|
def setMainWindowAllWidgetsStatusToDisabled():
|
||||||
vrct_gui._changeMainWindowWidgetsStatus("disabled", "All")
|
vrct_gui._changeMainWindowWidgetsStatus("disabled", "All")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def setTranslationSwitchStatus(status:str, to_lock_state:bool=False, release_locked_state:bool=False):
|
||||||
|
vrct_gui._changeMainWindowWidgetsStatus(status, ["translation_switch"], to_lock_state, release_locked_state)
|
||||||
|
|
||||||
def enableMainWindowSidebarCompactMode(self):
|
def enableMainWindowSidebarCompactMode(self):
|
||||||
self.view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE = True
|
self.view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE = True
|
||||||
@@ -996,7 +1013,9 @@ class View():
|
|||||||
self.view_variable.VAR_CTRANSLATE2_WEIGHT_TYPE.set(self.getSelectableCtranslate2WeightTypeDict()[selected_weight_type])
|
self.view_variable.VAR_CTRANSLATE2_WEIGHT_TYPE.set(self.getSelectableCtranslate2WeightTypeDict()[selected_weight_type])
|
||||||
|
|
||||||
def setLatestCTranslate2WeightType(self):
|
def setLatestCTranslate2WeightType(self):
|
||||||
selected_weight_type = self.getSelectableCtranslate2WeightTypeDict()[config.WEIGHT_TYPE]
|
if config.WEIGHT_TYPE == "m2m100_418m":
|
||||||
|
WEIGHT_TYPE = "Small"
|
||||||
|
selected_weight_type = self.getSelectableCtranslate2WeightTypeDict()[WEIGHT_TYPE]
|
||||||
self.view_variable.VAR_CTRANSLATE2_WEIGHT_TYPE.set(selected_weight_type)
|
self.view_variable.VAR_CTRANSLATE2_WEIGHT_TYPE.set(selected_weight_type)
|
||||||
|
|
||||||
|
|
||||||
@@ -1263,7 +1282,7 @@ class View():
|
|||||||
# vrct_gui.translation_frame.markToggleManually(False)
|
# vrct_gui.translation_frame.markToggleManually(False)
|
||||||
|
|
||||||
# # disable translation feature.
|
# # disable translation feature.
|
||||||
# vrct_gui._changeMainWindowWidgetsStatus("disabled", ["translation_switch"], to_hold_state=True)
|
# vrct_gui._changeMainWindowWidgetsStatus("disabled", ["translation_switch"], to_lock_state=True)
|
||||||
|
|
||||||
# # print system message that mention to stopped translation feature.
|
# # print system message that mention to stopped translation feature.
|
||||||
# view.printToTextbox_TranslationEngineLimitError()
|
# view.printToTextbox_TranslationEngineLimitError()
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
from customtkinter import CTkImage
|
from customtkinter import CTkImage
|
||||||
hold_state_list=[]
|
lock_state_list=[]
|
||||||
def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, target_names:list, to_hold_state:bool=False):
|
def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, target_names:list, to_lock_state:bool=False, release_locked_state:bool=False):
|
||||||
global hold_state_list
|
global lock_state_list
|
||||||
if target_names == "All":
|
if target_names == "All":
|
||||||
target_names = ["translation_switch", "transcription_send_switch", "transcription_receive_switch", "foreground_switch", "quick_language_settings", "config_button", "minimize_sidebar_button", "entry_message_box", "send_message_button"]
|
target_names = ["translation_switch", "transcription_send_switch", "transcription_receive_switch", "foreground_switch", "quick_language_settings", "config_button", "minimize_sidebar_button", "entry_message_box", "send_message_button"]
|
||||||
|
|
||||||
|
if release_locked_state is True:
|
||||||
|
for item in target_names:
|
||||||
|
if item in lock_state_list:
|
||||||
|
lock_state_list.remove(item)
|
||||||
|
|
||||||
for item in hold_state_list:
|
for item in lock_state_list:
|
||||||
if item in target_names:
|
if item in target_names:
|
||||||
target_names.remove(item)
|
target_names.remove(item)
|
||||||
|
|
||||||
@@ -158,9 +162,9 @@ def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, ta
|
|||||||
raise ValueError(f"No matching case for target_name: {target_name}")
|
raise ValueError(f"No matching case for target_name: {target_name}")
|
||||||
|
|
||||||
|
|
||||||
if to_hold_state is True:
|
if to_lock_state is True:
|
||||||
for item in target_names:
|
for item in target_names:
|
||||||
if item not in hold_state_list:
|
if item not in lock_state_list:
|
||||||
hold_state_list.append(item)
|
lock_state_list.append(item)
|
||||||
|
|
||||||
vrct_gui.update()
|
vrct_gui.update()
|
||||||
@@ -344,11 +344,11 @@ 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)
|
main_window.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, pady=settings.uism.SLS__SELECTABLE_TRANSLATION_PADY, sticky="ew")
|
main_window.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=0, minsize=settings.uism.SLS__SELECTABLE_TRANSLATION_MIN_PADX)
|
main_window.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.sls__box_translation_optionmenu_wrapper.grid_columnconfigure(1, weight=1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -361,12 +361,12 @@ def createSidebarLanguagesSettings(settings, main_window, view_variable):
|
|||||||
dropdown_menu_values=[],
|
dropdown_menu_values=[],
|
||||||
command=adjustedCommand,
|
command=adjustedCommand,
|
||||||
wrapper_widget=main_window,
|
wrapper_widget=main_window,
|
||||||
attach_widget=sls__box_translation_optionmenu_wrapper,
|
attach_widget=main_window.sls__box_translation_optionmenu_wrapper,
|
||||||
dropdown_menu_min_width=settings.uism.SIDEBAR_MIN_WIDTH,
|
dropdown_menu_min_width=settings.uism.SIDEBAR_MIN_WIDTH,
|
||||||
)
|
)
|
||||||
|
|
||||||
(sls__selected_translation_engine_box, label_button_label_widget) = createLabelButton(
|
(sls__selected_translation_engine_box, label_button_label_widget) = createLabelButton(
|
||||||
parent_widget=sls__box_translation_optionmenu_wrapper,
|
parent_widget=main_window.sls__box_translation_optionmenu_wrapper,
|
||||||
label_button_bg_color=settings.ctm.SLS__BG_COLOR,
|
label_button_bg_color=settings.ctm.SLS__BG_COLOR,
|
||||||
label_button_hovered_bg_color=settings.ctm.SLS__OPTIONMENU_HOVERED_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_clicked_bg_color=settings.ctm.SLS__OPTIONMENU_CLICKED_BG_COLOR,
|
||||||
|
|||||||
@@ -250,14 +250,15 @@ class VRCT_GUI(CTk):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _changeMainWindowWidgetsStatus(self, status, target_names, to_hold_state:bool=False):
|
def _changeMainWindowWidgetsStatus(self, status, target_names, to_lock_state:bool=False, release_locked_state:bool=False):
|
||||||
_changeMainWindowWidgetsStatus(
|
_changeMainWindowWidgetsStatus(
|
||||||
vrct_gui=self,
|
vrct_gui=self,
|
||||||
settings=self.settings.main,
|
settings=self.settings.main,
|
||||||
view_variable=self._view_variable,
|
view_variable=self._view_variable,
|
||||||
status=status,
|
status=status,
|
||||||
target_names=target_names,
|
target_names=target_names,
|
||||||
to_hold_state=to_hold_state,
|
to_lock_state=to_lock_state,
|
||||||
|
release_locked_state=release_locked_state,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _changeConfigWindowWidgetsStatus(self, status, target_names):
|
def _changeConfigWindowWidgetsStatus(self, status, target_names):
|
||||||
|
|||||||
Reference in New Issue
Block a user