diff --git a/ctk_scrollable_dropdown.py b/ctk_scrollable_dropdown.py deleted file mode 100644 index f0f48c3e..00000000 --- a/ctk_scrollable_dropdown.py +++ /dev/null @@ -1,350 +0,0 @@ -""" -CustomTkinter Scrollable Dropdown Menu -Author: Akash Bora -License: MIT -This is a custom dropdown menu for customtkinter. -Homepage: https://github.com/Akascape/CTkScrollableDropdown - -Advanced Scrollable Dropdown class for customtkinter widgets -Author: Akash Bora -""" -import customtkinter -import sys -import time - -class CTkScrollableDropdown(customtkinter.CTkToplevel): - - def __init__(self, attach, x=None, y=None, button_color=None, height: int = 200, width: int = None, - fg_color=None, max_button_height: int = 20, justify="center", scrollbar_button_color=None, - scrollbar=True, scrollbar_button_hover_color=None, frame_border_width=2, values=[], - command=None, image_values=[], alpha: float = 0.97, double_click=False, - resize=True, frame_border_color=None, text_color=None, autocomplete=False, - max_height: int = None, button_pady: int = 0, min_show_button_num: int = 1, - button_corner_radius: int = None, frame_corner_radius=0, - **button_kwargs): - - super().__init__(takefocus=1) - self.transient(self.master) - self.alpha = alpha - self.attach = attach - self.corner = frame_corner_radius - # とりあえずframe_corner_radiusはframe_corner_radiusの名前のまま使いたい - self.frame_corner_radius = frame_corner_radius - self.padding = 0 - self.focus_something = False - self.disable = True - self.font_size = 12 if button_kwargs.get("font", None) is None else button_kwargs["font"]._size - - if sys.platform.startswith("win"): - self.after(100, lambda: self.overrideredirect(True)) - self.transparent_color = self._apply_appearance_mode(self._fg_color) - self.attributes("-transparentcolor", self.transparent_color) - elif sys.platform.startswith("darwin"): - self.overrideredirect(True) - self.transparent_color = 'systemTransparent' - self.attributes("-transparent", True) - self.focus_something = True - else: - self.overrideredirect(True) - self.transparent_color = '#000001' - self.corner = 0 - self.padding = 18 - self.withdraw() - - self.hide = True - self.attach.bind('', lambda e: self._withdraw() if not self.disable else None, add="+") - self.attach.winfo_toplevel().bind('', lambda e: self._withdraw() if not self.disable else None, add="+") - self.attach.winfo_toplevel().bind("", lambda e: self._withdraw() if not self.disable else None, add="+") - self.attach.winfo_toplevel().bind("", lambda e: self._withdraw() if not self.disable else None, add="+") - self.attach.winfo_toplevel().bind("", lambda e: self._withdraw() if not self.disable else None, add="+") - - self.attributes('-alpha', 0) - self.disable = False - self.fg_color = customtkinter.ThemeManager.theme["CTkFrame"]["fg_color"] if fg_color is None else fg_color - self.scroll_button_color = customtkinter.ThemeManager.theme["CTkScrollbar"]["button_color"] if scrollbar_button_color is None else scrollbar_button_color - self.scroll_hover_color = customtkinter.ThemeManager.theme["CTkScrollbar"]["button_hover_color"] if scrollbar_button_hover_color is None else scrollbar_button_hover_color - self.frame_border_color = customtkinter.ThemeManager.theme["CTkFrame"]["border_color"] if frame_border_color is None else frame_border_color - self.button_color = customtkinter.ThemeManager.theme["CTkFrame"]["top_fg_color"] if button_color is None else button_color - self.text_color = customtkinter.ThemeManager.theme["CTkLabel"]["text_color"] if text_color is None else text_color - - if scrollbar is False: - self.scroll_button_color = self.fg_color - self.scroll_hover_color = self.fg_color - - self.frame = customtkinter.CTkScrollableFrame(self, bg_color=self.transparent_color, fg_color=self.fg_color, - scrollbar_button_hover_color=self.scroll_hover_color, - corner_radius=self.corner, border_width=frame_border_width, - scrollbar_button_color=self.scroll_button_color, - border_color=self.frame_border_color) - self.frame._scrollbar.grid_configure(padx=3) - self.frame.pack(expand=True, fill="both") - - self.dummy_entry = customtkinter.CTkEntry(self.frame, fg_color="transparent", border_width=0, height=1, width=1) - self.no_match = customtkinter.CTkLabel(self.frame, text="No Match") - self.height = height - self.height_new = height - self.width = width - self.command = command - self.fade = False - self.resize = resize - self.autocomplete = autocomplete - self.var_update = customtkinter.StringVar() - self.appear = False - self.max_height = max_height - self.button_pady = button_pady - self.min_show_button_num = min_show_button_num - self.button_corner_radius = button_corner_radius - - if justify.lower()=="left": - self.justify = "w" - elif justify.lower()=="right": - self.justify = "e" - else: - self.justify = "c" - - self.button_height = max_button_height + self.font_size - self.values = values - self.button_num = len(self.values) - self.image_values = None if len(image_values)!=len(self.values) else image_values - - self.resizable(width=False, height=False) - self._init_buttons(**button_kwargs) - - # Add binding for different ctk widgets - if double_click or self.attach.winfo_name().startswith("!ctkentry") or self.attach.winfo_name().startswith("!ctkcombobox"): - self.attach.bind('', lambda e: self._iconify(), add="+") - else: - self.attach.bind('', lambda e: self._iconify(), add="+") - - if self.attach.winfo_name().startswith("!ctkcombobox"): - self.attach._canvas.tag_bind("right_parts", "", lambda e: self._iconify()) - self.attach._canvas.tag_bind("dropdown_arrow", "", lambda e: self._iconify()) - if self.command is None: - self.command = self.attach.set - - if self.attach.winfo_name().startswith("!ctkoptionmenu"): - self.attach._canvas.bind("", lambda e: self._iconify()) - self.attach._text_label.bind("", lambda e: self._iconify()) - if self.command is None: - self.command = self.attach.set - - self.update_idletasks() - self.x = x - self.y = y - - if self.autocomplete: - self.bind_autocomplete() - - # self.deiconify() - self.withdraw() - - self.attributes("-alpha", self.alpha) - - def _withdraw(self): - if self.hide is False: self.withdraw() - self.hide = True - - def _update(self, a, b, c): - self.live_update(self.attach._entry.get()) - - def bind_autocomplete(self, ): - def appear(x): - self.appear = True - - if self.attach.winfo_name().startswith("!ctkcombobox"): - self.attach._entry.configure(textvariable=self.var_update) - self.attach._entry.bind("", appear) - self.attach.set(self.values[0]) - self.var_update.trace_add('write', self._update) - - if self.attach.winfo_name().startswith("!ctkentry"): - self.attach.configure(textvariable=self.var_update) - self.attach.bind("", appear) - self.var_update.trace_add('write', self._update) - - def fade_out(self): - for i in range(100,0,-10): - if not self.winfo_exists(): - break - self.attributes("-alpha", i/100) - self.update() - time.sleep(1/100) - - def fade_in(self): - for i in range(0,100,10): - if not self.winfo_exists(): - break - self.attributes("-alpha", i/100) - self.update() - time.sleep(1/100) - - def _init_buttons(self, **button_kwargs): - self.i = 0 - self.widgets = {} - for row in self.values: - self.widgets[self.i] = customtkinter.CTkButton(self.frame, - text=row, - height=self.button_height, - fg_color=self.button_color, - text_color=self.text_color, - image=self.image_values[i] if self.image_values is not None else None, - anchor=self.justify, - corner_radius= self.button_corner_radius, - command=lambda k=row: self._attach_key_press(k), **button_kwargs) - pady = 0 if self.button_num-1 == self.i else self.button_pady - self.widgets[self.i].pack(fill="x", pady=(0, pady), padx=(self.padding, 0)) - self.i+=1 - - self.hide = False - - def destroy_popup(self): - self.destroy() - self.disable = True - - def place_dropdown(self): - self.x_pos = self.attach.winfo_rootx() if self.x is None else self.x + self.attach.winfo_rootx() - self.y_pos = self.attach.winfo_rooty() + self.attach.winfo_reqheight() + 5 if self.y is None else self.y + self.attach.winfo_rooty() - self.width_new = self.attach.winfo_width() if self.width is None else self.width - - if self.resize: - button_height_include_pady = self.button_height + self.button_pady - - if self.min_show_button_num < self.button_num: - min_buttons_height = button_height_include_pady * self.min_show_button_num - else: - min_buttons_height = button_height_include_pady * self.button_num - # delete last one's pady px - min_buttons_height -= self.button_pady - - # minor adjustment + 5px - min_buttons_height += 5 - # adjust by frame_corner_radius - min_buttons_height += (self.frame_corner_radius * 2) - - if self.max_height: - if min_buttons_height>self.max_height: - min_buttons_height = self.max_height - - self.height_new = min_buttons_height - - self.geometry('{}x{}+{}+{}'.format(self.width_new, self.height_new, - self.x_pos, self.y_pos)) - self.fade_in() - self.attributes('-alpha', self.alpha) - - def _iconify(self): - if self.disable: return - if self.hide: - self._deiconify() - self.place_dropdown() - if self.focus_something: - self.dummy_entry.pack() - self.dummy_entry.focus_set() - self.after(100, self.dummy_entry.pack_forget) - self.hide = False - self.focus_set() - self.focus() - else: - self.withdraw() - self.hide = True - - def _attach_key_press(self, k): - self.fade = True - if self.command: - self.command(k) - self.fade = False - self.fade_out() - self.withdraw() - self.hide = True - - def live_update(self, string=None): - if not self.appear: return - if self.disable: return - if self.fade: return - if string: - self._deiconify() - i=1 - for key in self.widgets.keys(): - s = self.widgets[key].cget("text") - if not s.startswith(string): - self.widgets[key].pack_forget() - else: - self.widgets[key].pack(fill="x", pady=2, padx=(self.padding, 0)) - i+=1 - - if i==1: - self.no_match.pack(fill="x", pady=2, padx=(self.padding, 0)) - else: - self.no_match.pack_forget() - self.button_num = i - self.place_dropdown() - - else: - self.no_match.pack_forget() - self.button_num = len(self.values) - for key in self.widgets.keys(): - self.widgets[key].destroy() - self._init_buttons() - self.place_dropdown() - - self.frame._parent_canvas.yview_moveto(0.0) - self.appear = False - - def insert(self, value, **kwargs): - self.widgets[self.i] = customtkinter.CTkButton(self.frame, - text=value, - height=self.button_height, - fg_color=self.button_color, - text_color=self.text_color, - anchor=self.justify, - command=lambda k=value: self._attach_key_press(k), **kwargs) - self.widgets[self.i].pack(fill="x", pady=2, padx=(self.padding, 0)) - self.i+=1 - self.values.append(value) - - def _deiconify(self): - if len(self.values)>0: - self.deiconify() - - def popup(self, x=None, y=None): - self.x = x - self.y = y - self.hide = True - self._iconify() - - def configure(self, **kwargs): - if "height" in kwargs: - self.height = kwargs.pop("height") - self.height_new = self.height - - if "alpha" in kwargs: - self.alpha = kwargs.pop("alpha") - - if "width" in kwargs: - self.width = kwargs.pop("width") - - if "fg_color" in kwargs: - self.frame.configure(fg_color=kwargs.pop("fg_color")) - - if "values" in kwargs: - self.values = kwargs.pop("values") - self.image_values = None - for key in self.widgets.keys(): - self.widgets[key].destroy() - self._init_buttons() - - if "image_values" in kwargs: - self.image_values = kwargs.pop("image_values") - self.image_values = None if len(self.image_values)!=len(self.values) else self.image_values - if self.image_values is not None: - i=0 - for key in self.widgets.keys(): - self.widgets[key].configure(image=self.image_values[i]) - i+=1 - - if "button_color" in kwargs: - for key in self.widgets.keys(): - self.widgets[key].configure(fg_color=kwargs.pop("button_color")) - - for key in self.widgets.keys(): - self.widgets[key].configure(**kwargs) diff --git a/window_config.py b/window_config.py deleted file mode 100644 index b45a61c1..00000000 --- a/window_config.py +++ /dev/null @@ -1,1344 +0,0 @@ -from os import path as os_path -from tkinter import DoubleVar, IntVar -from tkinter import font as tk_font -import customtkinter -from customtkinter import CTkToplevel, CTkTabview, CTkFont, CTkLabel, CTkSlider, CTkOptionMenu, StringVar, CTkEntry, CTkCheckBox, CTkProgressBar - -from threading import Thread -from config import config -from model import model -from utils import print_textbox, get_localized_text, get_key_by_value, widget_config_window_label_setter -from languages import selectable_languages -from models.translation.translation_languages import translation_lang -from models.transcription.transcription_languages import transcription_lang -from ctk_scrollable_dropdown import CTkScrollableDropdown - -SCROLLABLE_DROPDOWN = False - -class ToplevelWindowConfig(CTkToplevel): - - def __init__(self, parent, *args, **kwargs): - super().__init__(parent, *args, **kwargs) - - self.withdraw() - self.parent = parent - # self.geometry(f"{350}x{270}") - # self.resizable(False, False) - self.grid_columnconfigure(0, weight=1) - self.grid_rowconfigure(0, weight=1) - - self.after(200, lambda: self.iconbitmap(os_path.join(os_path.dirname(__file__), "img", "app.ico"))) - self.title("Config") - - # load ui language data - language_yaml_data = get_localized_text(f"{config.UI_LANGUAGE}") - # add tabview config - self.add_tabview_config(language_yaml_data, selectable_languages) - # set all config window labels - widget_config_window_label_setter(self, language_yaml_data) - - self.protocol("WM_DELETE_WINDOW", self.delete_window) - - def slider_transparency_callback(self, value): - self.parent.wm_attributes("-alpha", value/100) - config.TRANSPARENCY = value - - def optionmenu_appearance_theme_callback(self, choice): - self.optionmenu_appearance_theme.set(choice) - - customtkinter.set_appearance_mode(choice) - config.APPEARANCE_THEME = choice - - def optionmenu_ui_scaling_callback(self, choice): - self.optionmenu_ui_scaling.set(choice) - - new_scaling_float = int(choice.replace("%", "")) / 100 - customtkinter.set_widget_scaling(new_scaling_float) - config.UI_SCALING = choice - - def optionmenu_font_family_callback(self, choice): - self.optionmenu_font_family.set(choice) - - # tab menu - self.tabview_config._segmented_button.configure(font=CTkFont(family=choice)) - - # tab UI - self.label_transparency.configure(font=CTkFont(family=choice)) - self.label_appearance_theme.configure(font=CTkFont(family=choice)) - self.optionmenu_appearance_theme.configure(font=CTkFont(family=choice)) - self.optionmenu_appearance_theme._dropdown_menu.configure(font=CTkFont(family=choice)) - self.label_ui_scaling.configure(font=CTkFont(family=choice)) - self.optionmenu_ui_scaling.configure(font=CTkFont(family=choice)) - self.optionmenu_ui_scaling._dropdown_menu.configure(font=CTkFont(family=choice)) - self.label_font_family.configure(font=CTkFont(family=choice)) - self.optionmenu_font_family.configure(font=CTkFont(family=choice)) - self.optionmenu_font_family._dropdown_menu.configure(font=CTkFont(family=choice)) - self.label_ui_language.configure(font=CTkFont(family=choice)) - self.optionmenu_ui_language.configure(font=CTkFont(family=choice)) - self.optionmenu_ui_language._dropdown_menu.configure(font=CTkFont(family=choice)) - - # tab Translation - self.label_translation_translator.configure(font=CTkFont(family=choice)) - self.optionmenu_translation_translator.configure(font=CTkFont(family=choice)) - self.optionmenu_translation_translator._dropdown_menu.configure(font=CTkFont(family=choice)) - self.label_translation_input_language.configure(font=CTkFont(family=choice)) - self.optionmenu_translation_input_source_language.configure(font=CTkFont(family=choice)) - self.optionmenu_translation_input_source_language._dropdown_menu.configure(font=CTkFont(family=choice)) - self.label_translation_input_arrow.configure(font=CTkFont(family=choice)) - self.optionmenu_translation_input_target_language.configure(font=CTkFont(family=choice)) - self.optionmenu_translation_input_target_language._dropdown_menu.configure(font=CTkFont(family=choice)) - self.label_translation_output_language.configure(font=CTkFont(family=choice)) - self.optionmenu_translation_output_source_language.configure(font=CTkFont(family=choice)) - self.optionmenu_translation_output_source_language._dropdown_menu.configure(font=CTkFont(family=choice)) - self.label_translation_output_arrow.configure(font=CTkFont(family=choice)) - self.optionmenu_translation_output_target_language.configure(font=CTkFont(family=choice)) - self.optionmenu_translation_output_target_language._dropdown_menu.configure(font=CTkFont(family=choice)) - - # tab Transcription - self.label_input_mic_host.configure(font=CTkFont(family=choice)) - self.optionmenu_input_mic_host.configure(font=CTkFont(family=choice)) - self.optionmenu_input_mic_host._dropdown_menu.configure(font=CTkFont(family=choice)) - self.label_input_mic_device.configure(font=CTkFont(family=choice)) - self.optionmenu_input_mic_device.configure(font=CTkFont(family=choice)) - self.optionmenu_input_mic_device._dropdown_menu.configure(font=CTkFont(family=choice)) - self.label_input_mic_voice_language.configure(font=CTkFont(family=choice)) - self.optionmenu_input_mic_voice_language.configure(font=CTkFont(family=choice)) - self.optionmenu_input_mic_voice_language._dropdown_menu.configure(font=CTkFont(family=choice)) - self.checkbox_input_mic_threshold_check.configure(font=CTkFont(family=choice)) - self.label_input_mic_energy_threshold.configure(font=CTkFont(family=choice)) - self.label_input_mic_dynamic_energy_threshold.configure(font=CTkFont(family=choice)) - self.label_input_mic_record_timeout.configure(font=CTkFont(family=choice)) - self.entry_input_mic_record_timeout.configure(font=CTkFont(family=choice)) - self.label_input_mic_phrase_timeout.configure(font=CTkFont(family=choice)) - self.entry_input_mic_phrase_timeout.configure(font=CTkFont(family=choice)) - self.label_input_mic_max_phrases.configure(font=CTkFont(family=choice)) - self.entry_input_mic_max_phrases.configure(font=CTkFont(family=choice)) - self.label_input_mic_word_filter.configure(font=CTkFont(family=choice)) - self.entry_input_mic_word_filter.configure(font=CTkFont(family=choice)) - self.label_input_speaker_device.configure(font=CTkFont(family=choice)) - self.optionmenu_input_speaker_device.configure(font=CTkFont(family=choice)) - self.optionmenu_input_speaker_device._dropdown_menu.configure(font=CTkFont(family=choice)) - self.label_input_speaker_voice_language.configure(font=CTkFont(family=choice)) - self.optionmenu_input_speaker_voice_language.configure(font=CTkFont(family=choice)) - self.optionmenu_input_speaker_voice_language._dropdown_menu.configure(font=CTkFont(family=choice)) - self.checkbox_input_speaker_threshold_check.configure(font=CTkFont(family=choice)) - self.label_input_speaker_energy_threshold.configure(font=CTkFont(family=choice)) - self.label_input_speaker_dynamic_energy_threshold.configure(font=CTkFont(family=choice)) - self.label_input_speaker_record_timeout.configure(font=CTkFont(family=choice)) - self.entry_input_speaker_record_timeout.configure(font=CTkFont(family=choice)) - self.label_input_speaker_phrase_timeout.configure(font=CTkFont(family=choice)) - self.entry_input_speaker_phrase_timeout.configure(font=CTkFont(family=choice)) - self.label_input_speaker_max_phrases.configure(font=CTkFont(family=choice)) - self.entry_input_speaker_max_phrases.configure(font=CTkFont(family=choice)) - - # tab Parameter - self.label_ip_address.configure(font=CTkFont(family=choice)) - self.entry_ip_address.configure(font=CTkFont(family=choice)) - self.label_port.configure(font=CTkFont(family=choice)) - self.entry_port.configure(font=CTkFont(family=choice)) - self.label_authkey.configure(font=CTkFont(family=choice)) - self.entry_authkey.configure(font=CTkFont(family=choice)) - self.label_message_format.configure(font=CTkFont(family=choice)) - self.entry_message_format.configure(font=CTkFont(family=choice)) - - # tab Others - self.label_checkbox_auto_clear_chatbox.configure(font=CTkFont(family=choice)) - - # main window - self.parent.checkbox_translation.configure(font=CTkFont(family=choice)) - self.parent.checkbox_transcription_send.configure(font=CTkFont(family=choice)) - self.parent.checkbox_transcription_receive.configure(font=CTkFont(family=choice)) - self.parent.checkbox_foreground.configure(font=CTkFont(family=choice)) - self.parent.textbox_message_log.configure(font=CTkFont(family=choice)) - self.parent.textbox_message_send_log.configure(font=CTkFont(family=choice)) - self.parent.textbox_message_receive_log.configure(font=CTkFont(family=choice)) - self.parent.textbox_message_system_log.configure(font=CTkFont(family=choice)) - self.parent.entry_message_box.configure(font=CTkFont(family=choice)) - self.parent.tabview_logs._segmented_button.configure(font=CTkFont(family=choice)) - - # window information - try: - self.parent.information_window.textbox_information.configure(font=CTkFont(family=choice)) - except: - pass - - config.FONT_FAMILY = choice - - def optionmenu_ui_language_callback(self, choice): - self.optionmenu_ui_language.set(choice) - - self.withdraw() - pre_language_yaml_data = get_localized_text(f"{config.UI_LANGUAGE}") - config.UI_LANGUAGE = get_key_by_value(selectable_languages, choice) - language_yaml_data = get_localized_text(f"{config.UI_LANGUAGE}") - - # delete - self.parent.delete_tabview_logs(pre_language_yaml_data) - self.delete_tabview_config(pre_language_yaml_data) - # add tabview textbox - self.parent.add_tabview_logs(language_yaml_data) - self.add_tabview_config(language_yaml_data, selectable_languages) - - # 翻訳予定 - # window information - # try: - # self.parent.information_window.textbox_information.configure(font=customtkinter.CTkFont(family=choice)) - # except: - # pass - self.deiconify() - - def optionmenu_translation_translator_callback(self, choice): - self.optionmenu_translation_translator.set(choice) - - if model.authenticationTranslator(choice_translator=choice) is False: - print_textbox(self.parent.textbox_message_log, "Auth Key or language setting is incorrect", "ERROR") - print_textbox(self.parent.textbox_message_system_log, "Auth Key or language setting is incorrect", "ERROR") - else: - self.optionmenu_translation_input_source_language.configure( - values=list(translation_lang[choice]["source"].keys()), - variable=StringVar(value=list(translation_lang[choice]["source"].keys())[0])) - self.optionmenu_translation_input_target_language.configure( - values=list(translation_lang[choice]["target"].keys()), - variable=StringVar(value=list(translation_lang[choice]["target"].keys())[1])) - self.optionmenu_translation_output_source_language.configure( - values=list(translation_lang[choice]["source"].keys()), - variable=StringVar(value=list(translation_lang[choice]["source"].keys())[1])) - self.optionmenu_translation_output_target_language.configure( - values=list(translation_lang[choice]["target"].keys()), - variable=StringVar(value=list(translation_lang[choice]["target"].keys())[0])) - - if SCROLLABLE_DROPDOWN: - self.scrollableDropdown_translation_input_source_language.configure( - values=list(translation_lang[choice]["source"].keys())) - self.scrollableDropdown_translation_input_target_language.configure( - values=list(translation_lang[choice]["target"].keys())) - self.scrollableDropdown_translation_output_source_language.configure( - values=list(translation_lang[choice]["source"].keys())) - self.scrollableDropdown_translation_output_target_language.configure( - values=list(translation_lang[choice]["target"].keys())) - - config.CHOICE_TRANSLATOR = choice - config.INPUT_SOURCE_LANG = list(translation_lang[choice]["source"].keys())[0] - config.INPUT_TARGET_LANG = list(translation_lang[choice]["target"].keys())[1] - config.OUTPUT_SOURCE_LANG = list(translation_lang[choice]["source"].keys())[1] - config.OUTPUT_TARGET_LANG = list(translation_lang[choice]["target"].keys())[0] - - def optionmenu_translation_input_source_language_callback(self, choice): - self.optionmenu_translation_input_source_language.set(choice) - config.INPUT_SOURCE_LANG = choice - - def optionmenu_translation_input_target_language_callback(self, choice): - self.optionmenu_translation_input_target_language.set(choice) - config.INPUT_TARGET_LANG = choice - - def optionmenu_translation_output_source_language_callback(self, choice): - self.optionmenu_translation_output_source_language.set(choice) - config.OUTPUT_SOURCE_LANG = choice - - def optionmenu_translation_output_target_language_callback(self, choice): - self.optionmenu_translation_output_target_language.set(choice) - config.OUTPUT_TARGET_LANG = choice - - def optionmenu_input_mic_host_callback(self, choice): - self.optionmenu_input_mic_host.set(choice) - config.CHOICE_MIC_HOST = choice - config.CHOICE_MIC_DEVICE = model.getInputDefaultDevice() - - self.optionmenu_input_mic_device.configure( - values=model.getListInputDevice(), - variable=StringVar(value=model.getInputDefaultDevice())) - - if SCROLLABLE_DROPDOWN: - self.scrollableDropdown_input_mic_device.configure(values=model.getListInputDevice()) - - def optionmenu_input_mic_device_callback(self, choice): - self.optionmenu_input_mic_device.set(choice) - config.CHOICE_MIC_DEVICE = choice - self.checkbox_input_mic_threshold_check.deselect() - self.checkbox_input_mic_threshold_check_callback() - - def optionmenu_input_mic_voice_language_callback(self, choice): - self.optionmenu_input_mic_voice_language.set(choice) - config.INPUT_MIC_VOICE_LANGUAGE = choice - - def mic_threshold_check_start(self): - def plotProgressBar(energy): - try: - self.progressBar_input_mic_energy_threshold.set(energy/config.MAX_MIC_ENERGY_THRESHOLD) - except: - pass - model.startCheckMicEnergy(plotProgressBar) - self.checkbox_input_mic_threshold_check.configure(state="normal") - self.checkbox_input_speaker_threshold_check.configure(state="normal") - - def mic_threshold_check_stop(self): - model.stopCheckMicEnergy() - self.progressBar_input_mic_energy_threshold.set(0) - self.checkbox_input_mic_threshold_check.configure(state="normal") - self.checkbox_input_speaker_threshold_check.configure(state="normal") - - def checkbox_input_mic_threshold_check_callback(self): - self.checkbox_input_mic_threshold_check.configure(state="disabled") - self.checkbox_input_speaker_threshold_check.configure(state="disabled") - self.update() - if self.checkbox_input_mic_threshold_check.get(): - th_mic_threshold_check_start = Thread(target=self.mic_threshold_check_start) - th_mic_threshold_check_start.daemon = True - th_mic_threshold_check_start.start() - else: - th_mic_threshold_check_stop = Thread(target=self.mic_threshold_check_stop) - th_mic_threshold_check_stop.daemon = True - th_mic_threshold_check_stop.start() - - def slider_input_mic_energy_threshold_callback(self, value): - config.INPUT_MIC_ENERGY_THRESHOLD = int(value) - - def checkbox_input_mic_dynamic_energy_threshold_callback(self): - config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD = self.checkbox_input_mic_dynamic_energy_threshold.get() - - def entry_input_mic_record_timeout_callback(self, event): - config.INPUT_MIC_RECORD_TIMEOUT = int(self.entry_input_mic_record_timeout.get()) - - def entry_input_mic_phrase_timeout_callback(self, event): - config.INPUT_MIC_PHRASE_TIMEOUT = int(self.entry_input_mic_phrase_timeout.get()) - - def entry_input_mic_max_phrases_callback(self, event): - config.INPUT_MIC_MAX_PHRASES = int(self.entry_input_mic_max_phrases.get()) - - def entry_input_mic_word_filters_callback(self, event): - word_filter = self.entry_input_mic_word_filter.get() - word_filter = [w.strip() for w in word_filter.split(",") if len(w.strip()) > 0] - word_filter = ",".join(word_filter) - if len(word_filter) > 0: - config.INPUT_MIC_WORD_FILTER = word_filter.split(",") - else: - config.INPUT_MIC_WORD_FILTER = [] - model.resetKeywordProcessor() - model.addKeywords() - - def optionmenu_input_speaker_device_callback(self, choice): - if model.checkSpeakerStatus(choice): - self.optionmenu_input_speaker_device.set(choice) - config.CHOICE_SPEAKER_DEVICE = choice - else: - print_textbox(self.parent.textbox_message_log, "Windows playback device and selected device do not match. Change the Windows playback device.", "ERROR") - print_textbox(self.parent.textbox_message_system_log, "Windows playback device and selected device do not match. Change the Windows playback device.", "ERROR") - self.optionmenu_input_speaker_device.configure(variable=StringVar(value=config.CHOICE_SPEAKER_DEVICE)) - - def optionmenu_input_speaker_voice_language_callback(self, choice): - self.optionmenu_input_speaker_voice_language.set(choice) - config.INPUT_SPEAKER_VOICE_LANGUAGE = choice - - def speaker_threshold_check_start(self): - def plotProgressBar(energy): - try: - self.progressBar_input_speaker_energy_threshold.set(energy/config.MAX_MIC_ENERGY_THRESHOLD) - except: - pass - model.startCheckSpeakerEnergy(plotProgressBar) - self.checkbox_input_mic_threshold_check.configure(state="normal") - self.checkbox_input_speaker_threshold_check.configure(state="normal") - - def speaker_threshold_check_stop(self): - model.stopCheckSpeakerEnergy() - self.progressBar_input_speaker_energy_threshold.set(0) - self.checkbox_input_mic_threshold_check.configure(state="normal") - self.checkbox_input_speaker_threshold_check.configure(state="normal") - - def checkbox_input_speaker_threshold_check_callback(self): - self.checkbox_input_mic_threshold_check.configure(state="disabled") - self.checkbox_input_speaker_threshold_check.configure(state="disabled") - self.update() - if self.checkbox_input_speaker_threshold_check.get(): - if model.checkSpeakerStatus(): - th_speaker_threshold_check_start = Thread(target=self.speaker_threshold_check_start) - th_speaker_threshold_check_start.daemon = True - th_speaker_threshold_check_start.start() - else: - print_textbox(self.parent.textbox_message_log, "Windows playback device and selected device do not match. Change the Windows playback device.", "ERROR") - print_textbox(self.parent.textbox_message_system_log, "Windows playback device and selected device do not match. Change the Windows playback device.", "ERROR") - self.checkbox_input_speaker_threshold_check.deselect() - else: - th_speaker_threshold_check_stop = Thread(target=self.speaker_threshold_check_stop) - th_speaker_threshold_check_stop.daemon = True - th_speaker_threshold_check_stop.start() - - def slider_input_speaker_energy_threshold_callback(self, value): - config.INPUT_SPEAKER_ENERGY_THRESHOLD = int(value) - - def checkbox_input_speaker_dynamic_energy_threshold_callback(self): - config.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = self.checkbox_input_speaker_dynamic_energy_threshold.get() - - def entry_input_speaker_record_timeout_callback(self, event): - config.INPUT_SPEAKER_RECORD_TIMEOUT = int(self.entry_input_speaker_record_timeout.get()) - - def entry_input_speaker_phrase_timeout_callback(self, event): - config.INPUT_SPEAKER_PHRASE_TIMEOUT = int(self.entry_input_speaker_phrase_timeout.get()) - - def entry_input_speaker_max_phrases_callback(self, event): - config.INPUT_SPEAKER_MAX_PHRASES = int(self.entry_input_speaker_max_phrases.get()) - - def entry_ip_address_callback(self, event): - config.OSC_IP_ADDRESS = self.entry_ip_address.get() - - def entry_port_callback(self, event): - config.OSC_PORT = self.entry_port.get() - - def entry_authkey_callback(self, event): - value = self.entry_authkey.get() - if len(value) > 0: - if model.authenticationTranslator(choice_translator="DeepL(auth)", auth_key=value) is True: - print_textbox(self.parent.textbox_message_log, "Auth key update completed", "INFO") - print_textbox(self.parent.textbox_message_system_log, "Auth key update completed", "INFO") - else: - pass - - def checkbox_auto_clear_chatbox_callback(self): - config.ENABLE_AUTO_CLEAR_CHATBOX = self.checkbox_auto_clear_chatbox.get() - - def checkbox_notice_xsoverlay_callback(self): - config.ENABLE_NOTICE_XSOVERLAY = self.checkbox_notice_xsoverlay.get() - - def delete_window(self): - self.checkbox_input_mic_threshold_check.deselect() - self.checkbox_input_speaker_threshold_check.deselect() - self.checkbox_input_mic_threshold_check_callback() - self.checkbox_input_speaker_threshold_check_callback() - self.parent.transcription_start() - self.parent.foreground_start() - self.parent.checkbox_translation.configure(state="normal") - self.parent.checkbox_transcription_send.configure(state="normal") - self.parent.checkbox_transcription_receive.configure(state="normal") - self.parent.checkbox_foreground.configure(state="normal") - self.parent.tabview_logs.configure(state="normal") - self.parent.textbox_message_log.configure(state="normal") - self.parent.textbox_message_send_log.configure(state="normal") - self.parent.textbox_message_receive_log.configure(state="normal") - self.parent.textbox_message_system_log.configure(state="normal") - self.parent.entry_message_box.configure(state="normal") - self.parent.button_config.configure(state="normal", fg_color=["#3B8ED0", "#1F6AA5"]) - self.parent.button_information.configure(state="normal", fg_color=["#3B8ED0", "#1F6AA5"]) - self.withdraw() - self.grab_release() - - def entry_message_format_callback(self, event): - value = self.entry_message_format.get() - if len(value) > 0: - config.MESSAGE_FORMAT = value - - def delete_tabview_config(self, pre_language_yaml_data): - self.tabview_config.delete(pre_language_yaml_data["config_tab_title_ui"]) - self.tabview_config.delete(pre_language_yaml_data["config_tab_title_translation"]) - self.tabview_config.delete(pre_language_yaml_data["config_tab_title_transcription"]) - self.tabview_config.delete(pre_language_yaml_data["config_tab_title_parameter"]) - self.tabview_config.delete(pre_language_yaml_data["config_tab_title_others"]) - - def add_tabview_config(self, language_yaml_data, selectable_languages): - config_tab_title_ui = language_yaml_data["config_tab_title_ui"] - config_tab_title_translation = language_yaml_data["config_tab_title_translation"] - config_tab_title_transcription = language_yaml_data["config_tab_title_transcription"] - config_tab_title_parameter = language_yaml_data["config_tab_title_parameter"] - config_tab_title_others = language_yaml_data["config_tab_title_others"] - - init_lang_text = "Loading..." - - # tabwiew config - self.tabview_config = CTkTabview(self) - self.tabview_config.grid(row=0, column=0, padx=5, pady=5, sticky="nsew") - self.tabview_config.add(config_tab_title_ui) - self.tabview_config.add(config_tab_title_translation) - self.tabview_config.add(config_tab_title_transcription) - self.tabview_config.add(config_tab_title_parameter) - self.tabview_config.add(config_tab_title_others) - self.tabview_config.tab(config_tab_title_ui).grid_columnconfigure(1, weight=1) - self.tabview_config.tab(config_tab_title_translation).grid_columnconfigure([1,2,3], weight=1) - self.tabview_config.tab(config_tab_title_transcription).grid_columnconfigure(1, weight=1) - self.tabview_config.tab(config_tab_title_parameter).grid_columnconfigure(1, weight=1) - self.tabview_config.tab(config_tab_title_others).grid_columnconfigure(1, weight=1) - self.tabview_config._segmented_button.configure(font=CTkFont(family=config.FONT_FAMILY)) - self.tabview_config._segmented_button.grid(sticky="W") - - # tab UI - ## slider transparency - row = 0 - padx = 5 - pady = 1 - self.label_transparency = CTkLabel( - self.tabview_config.tab(config_tab_title_ui), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_transparency.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.slider_transparency = CTkSlider( - self.tabview_config.tab(config_tab_title_ui), - from_=50, - to=100, - command=self.slider_transparency_callback, - variable=DoubleVar(value=config.TRANSPARENCY), - ) - self.slider_transparency.grid(row=row, column=1, columnspan=1, padx=padx, pady=10, sticky="nsew") - - ## optionmenu theme - row += 1 - self.label_appearance_theme = CTkLabel( - self.tabview_config.tab(config_tab_title_ui), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_appearance_theme.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.optionmenu_appearance_theme = CTkOptionMenu( - self.tabview_config.tab(config_tab_title_ui), - values=["Light", "Dark", "System"], - command=self.optionmenu_appearance_theme_callback, - variable=StringVar(value=config.APPEARANCE_THEME), - font=CTkFont(family=config.FONT_FAMILY), - dropdown_font=CTkFont(family=config.FONT_FAMILY), - ) - self.optionmenu_appearance_theme.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - - ## scrollableDropdown appearance theme - if SCROLLABLE_DROPDOWN: - self.scrollableDropdown_appearance_theme = CTkScrollableDropdown( - self.optionmenu_appearance_theme, - values=["Light", "Dark", "System"], - justify="left", - button_color="transparent", - command=self.optionmenu_appearance_theme_callback, - font=CTkFont(family=config.FONT_FAMILY), - ) - self.scrollableDropdown_appearance_theme.bind( - "", - lambda e: self.scrollableDropdown_appearance_theme._withdraw() if not str(e.widget).startswith(str(self.scrollableDropdown_appearance_theme.frame._parent_frame)) else None, - ) - - ## optionmenu UI scaling - row += 1 - self.label_ui_scaling = CTkLabel( - self.tabview_config.tab(config_tab_title_ui), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_ui_scaling.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.optionmenu_ui_scaling = CTkOptionMenu( - self.tabview_config.tab(config_tab_title_ui), - values=["80%", "90%", "100%", "110%", "120%"], - command=self.optionmenu_ui_scaling_callback, - variable=StringVar(value=config.UI_SCALING), - font=CTkFont(family=config.FONT_FAMILY), - dropdown_font=CTkFont(family=config.FONT_FAMILY), - ) - self.optionmenu_ui_scaling.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - - ## scrollableDropdown ui scaling - if SCROLLABLE_DROPDOWN: - self.scrollableDropdown_ui_scaling = CTkScrollableDropdown( - self.optionmenu_ui_scaling, - values=["80%", "90%", "100%", "110%", "120%"], - justify="left", - button_color="transparent", - command=self.optionmenu_ui_scaling_callback, - font=CTkFont(family=config.FONT_FAMILY), - ) - self.scrollableDropdown_ui_scaling.bind( - "", - lambda e: self.scrollableDropdown_ui_scaling._iconify() if not str(e.widget).startswith(str(self.scrollableDropdown_ui_scaling.frame._parent_frame)) else None, - ) - - ## optionmenu font family - row += 1 - self.label_font_family = CTkLabel( - self.tabview_config.tab(config_tab_title_ui), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_font_family.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - font_families = list(tk_font.families()) - self.optionmenu_font_family = CTkOptionMenu( - self.tabview_config.tab(config_tab_title_ui), - values=font_families, - command=self.optionmenu_font_family_callback, - variable=StringVar(value=config.FONT_FAMILY), - font=CTkFont(family=config.FONT_FAMILY), - dropdown_font=CTkFont(family=config.FONT_FAMILY), - ) - self.optionmenu_font_family.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - - ## scrollableDropdown font family - if SCROLLABLE_DROPDOWN: - self.scrollableDropdown_font_family = CTkScrollableDropdown( - self.optionmenu_font_family, - values=font_families, - justify="left", - button_color="transparent", - command=self.optionmenu_font_family_callback, - font=CTkFont(family=config.FONT_FAMILY), - ) - self.scrollableDropdown_font_family.bind( - "", - lambda e: self.scrollableDropdown_font_family._withdraw() if not str(e.widget).startswith(str(self.scrollableDropdown_font_family.frame._parent_frame)) else None, - ) - - ## optionmenu ui language - row += 1 - self.label_ui_language = CTkLabel( - self.tabview_config.tab(config_tab_title_ui), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_ui_language.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - selectable_languages_values = list(selectable_languages.values()) - self.optionmenu_ui_language = CTkOptionMenu( - self.tabview_config.tab(config_tab_title_ui), - values=selectable_languages_values, - command=self.optionmenu_ui_language_callback, - variable=StringVar(value=selectable_languages[config.UI_LANGUAGE]), - font=CTkFont(family=config.FONT_FAMILY), - dropdown_font=CTkFont(family=config.FONT_FAMILY), - ) - self.optionmenu_ui_language.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - - ## scrollableDropdown ui language - if SCROLLABLE_DROPDOWN: - self.scrollableDropdown_ui_language = CTkScrollableDropdown( - self.optionmenu_ui_language, - values=selectable_languages_values, - justify="left", - button_color="transparent", - command=self.optionmenu_ui_language_callback, - font=CTkFont(family=config.FONT_FAMILY), - ) - self.scrollableDropdown_ui_language.bind( - "", - lambda e: self.scrollableDropdown_ui_language._withdraw() if not str(e.widget).startswith(str(self.scrollableDropdown_ui_language.frame._parent_frame)) else None, - ) - - # tab Translation - ## optionmenu translation translator - row = 0 - padx = 5 - pady = 1 - self.label_translation_translator = CTkLabel( - self.tabview_config.tab(config_tab_title_translation), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY), - ) - self.label_translation_translator.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.optionmenu_translation_translator = CTkOptionMenu( - self.tabview_config.tab(config_tab_title_translation), - values=model.getListTranslatorName(), - command=self.optionmenu_translation_translator_callback, - variable=StringVar(value=config.CHOICE_TRANSLATOR), - font=CTkFont(family=config.FONT_FAMILY), - dropdown_font=CTkFont(family=config.FONT_FAMILY), - ) - self.optionmenu_translation_translator.grid(row=row, column=1, columnspan=3, padx=padx, pady=pady, sticky="nsew") - - ## scrollableDropdown translation translator - if SCROLLABLE_DROPDOWN: - self.scrollableDropdown_translation_translator = CTkScrollableDropdown( - self.optionmenu_translation_translator, - values=model.getListTranslatorName(), - justify="left", - button_color="transparent", - command=self.optionmenu_translation_translator_callback, - font=CTkFont(family=config.FONT_FAMILY), - ) - self.scrollableDropdown_translation_translator.bind( - "", - lambda e: self.scrollableDropdown_translation_translator._withdraw() if not str(e.widget).startswith(str(self.scrollableDropdown_translation_translator.frame._parent_frame)) else None, - ) - - ## optionmenu translation input language - row +=1 - self.label_translation_input_language = CTkLabel( - self.tabview_config.tab(config_tab_title_translation), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_translation_input_language.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - - ## select translation input source language - self.optionmenu_translation_input_source_language = CTkOptionMenu( - self.tabview_config.tab(config_tab_title_translation), - command=self.optionmenu_translation_input_source_language_callback, - values=list(translation_lang[config.CHOICE_TRANSLATOR]["source"].keys()), - variable=StringVar(value=config.INPUT_SOURCE_LANG), - font=CTkFont(family=config.FONT_FAMILY), - dropdown_font=CTkFont(family=config.FONT_FAMILY), - ) - self.optionmenu_translation_input_source_language.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - - ## scrollableDropdown translation input source language - if SCROLLABLE_DROPDOWN: - self.scrollableDropdown_translation_input_source_language = CTkScrollableDropdown( - self.optionmenu_translation_input_source_language, - values=list(translation_lang[config.CHOICE_TRANSLATOR]["source"].keys()), - justify="left", - button_color="transparent", - command=self.optionmenu_translation_input_source_language_callback, - font=CTkFont(family=config.FONT_FAMILY), - ) - self.scrollableDropdown_translation_input_source_language.bind( - "", - lambda e: self.scrollableDropdown_translation_input_source_language._withdraw() if not str(e.widget).startswith(str(self.scrollableDropdown_translation_input_source_language.frame._parent_frame)) else None, - ) - - ## label translation input arrow - self.label_translation_input_arrow = CTkLabel( - self.tabview_config.tab(config_tab_title_translation), - text="-->", - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_translation_input_arrow.grid(row=row, column=2, columnspan=1, padx=padx, pady=pady, sticky="nsew") - - ## select translation input target language - self.optionmenu_translation_input_target_language = CTkOptionMenu( - self.tabview_config.tab(config_tab_title_translation), - command=self.optionmenu_translation_input_target_language_callback, - values=list(translation_lang[config.CHOICE_TRANSLATOR]["target"].keys()), - variable=StringVar(value=config.INPUT_TARGET_LANG), - font=CTkFont(family=config.FONT_FAMILY), - dropdown_font=CTkFont(family=config.FONT_FAMILY), - ) - self.optionmenu_translation_input_target_language.grid(row=row, column=3, columnspan=1, padx=padx, pady=pady, sticky="nsew") - - ## scrollableDropdown translation input target language - if SCROLLABLE_DROPDOWN: - self.scrollableDropdown_translation_input_target_language = CTkScrollableDropdown( - self.optionmenu_translation_input_target_language, - values=list(translation_lang[config.CHOICE_TRANSLATOR]["target"].keys()), - justify="left", - button_color="transparent", - command=self.optionmenu_translation_input_target_language_callback, - font=CTkFont(family=config.FONT_FAMILY), - ) - self.scrollableDropdown_translation_input_target_language.bind( - "", - lambda e: self.scrollableDropdown_translation_input_target_language._withdraw() if not str(e.widget).startswith(str(self.scrollableDropdown_translation_input_target_language.frame._parent_frame)) else None, - ) - - ## optionmenu translation output language - row +=1 - self.label_translation_output_language = CTkLabel( - self.tabview_config.tab(config_tab_title_translation), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_translation_output_language.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - - ## select translation output source language - self.optionmenu_translation_output_source_language = CTkOptionMenu( - self.tabview_config.tab(config_tab_title_translation), - command=self.optionmenu_translation_output_source_language_callback, - values=list(translation_lang[config.CHOICE_TRANSLATOR]["source"].keys()), - variable=StringVar(value=config.OUTPUT_SOURCE_LANG), - font=CTkFont(family=config.FONT_FAMILY), - dropdown_font=CTkFont(family=config.FONT_FAMILY), - ) - self.optionmenu_translation_output_source_language.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - - ## scrollableDropdown translation output source language - if SCROLLABLE_DROPDOWN: - self.scrollableDropdown_translation_output_source_language = CTkScrollableDropdown( - self.optionmenu_translation_output_source_language, - values=list(translation_lang[config.CHOICE_TRANSLATOR]["source"].keys()), - justify="left", - button_color="transparent", - command=self.optionmenu_translation_output_source_language_callback, - font=CTkFont(family=config.FONT_FAMILY), - ) - self.scrollableDropdown_translation_output_source_language.bind( - "", - lambda e: self.scrollableDropdown_translation_output_source_language._withdraw() if not str(e.widget).startswith(str(self.scrollableDropdown_translation_output_source_language.frame._parent_frame)) else None, - ) - - ## label translation output arrow - self.label_translation_output_arrow = CTkLabel( - self.tabview_config.tab(config_tab_title_translation), - text="-->", - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_translation_output_arrow.grid(row=row, column=2, columnspan=1, padx=padx, pady=pady, sticky="nsew") - - ## select translation output target language - self.optionmenu_translation_output_target_language = CTkOptionMenu( - self.tabview_config.tab(config_tab_title_translation), - command=self.optionmenu_translation_output_target_language_callback, - values=list(translation_lang[config.CHOICE_TRANSLATOR]["target"].keys()), - variable=StringVar(value=config.OUTPUT_TARGET_LANG), - font=CTkFont(family=config.FONT_FAMILY), - dropdown_font=CTkFont(family=config.FONT_FAMILY), - ) - self.optionmenu_translation_output_target_language.grid(row=row, column=3, columnspan=1, padx=padx, pady=pady, sticky="nsew") - - ## scrollableDropdown translation output target language - if SCROLLABLE_DROPDOWN: - self.scrollableDropdown_translation_output_target_language = CTkScrollableDropdown( - self.optionmenu_translation_output_target_language, - values=list(translation_lang[config.CHOICE_TRANSLATOR]["target"].keys()), - justify="left", - button_color="transparent", - command=self.optionmenu_translation_output_target_language_callback, - font=CTkFont(family=config.FONT_FAMILY), - ) - self.scrollableDropdown_translation_output_target_language.bind( - "", - lambda e: self.scrollableDropdown_translation_output_target_language._withdraw() if not str(e.widget).startswith(str(self.scrollableDropdown_translation_output_target_language.frame._parent_frame)) else None, - ) - - # tab Transcription - ## optionmenu input mic device's host - row = 0 - padx = 5 - pady = 1 - self.label_input_mic_host = CTkLabel( - self.tabview_config.tab(config_tab_title_transcription), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_input_mic_host.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.optionmenu_input_mic_host = CTkOptionMenu( - self.tabview_config.tab(config_tab_title_transcription), - values=model.getListInputHost(), - command=self.optionmenu_input_mic_host_callback, - variable=StringVar(value=config.CHOICE_MIC_HOST), - font=CTkFont(family=config.FONT_FAMILY), - dropdown_font=CTkFont(family=config.FONT_FAMILY), - ) - self.optionmenu_input_mic_host.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - - ## scrollableDropdown input mic device's host - if SCROLLABLE_DROPDOWN: - self.scrollableDropdown_input_mic_host = CTkScrollableDropdown( - self.optionmenu_input_mic_host, - values=model.getListInputHost(), - justify="left", - button_color="transparent", - command=self.optionmenu_input_mic_host_callback, - font=CTkFont(family=config.FONT_FAMILY), - ) - self.scrollableDropdown_input_mic_host.bind( - "", - lambda e: self.scrollableDropdown_input_mic_host._withdraw() if not str(e.widget).startswith(str(self.scrollableDropdown_input_mic_host.frame._parent_frame)) else None, - ) - - ## optionmenu input mic device - row += 1 - self.label_input_mic_device = CTkLabel( - self.tabview_config.tab(config_tab_title_transcription), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_input_mic_device.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.optionmenu_input_mic_device = CTkOptionMenu( - self.tabview_config.tab(config_tab_title_transcription), - values=model.getListInputDevice(), - command=self.optionmenu_input_mic_device_callback, - variable=StringVar(value=config.CHOICE_MIC_DEVICE), - font=CTkFont(family=config.FONT_FAMILY), - dropdown_font=CTkFont(family=config.FONT_FAMILY), - ) - self.optionmenu_input_mic_device.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - - ## scrollableDropdown input mic device - if SCROLLABLE_DROPDOWN: - self.scrollableDropdown_input_mic_device = CTkScrollableDropdown( - self.optionmenu_input_mic_device, - values=model.getListInputDevice(), - justify="left", - button_color="transparent", - command=self.optionmenu_input_mic_device_callback, - font=CTkFont(family=config.FONT_FAMILY), - ) - self.scrollableDropdown_input_mic_device.bind( - "", - lambda e: self.scrollableDropdown_input_mic_device._withdraw() if not str(e.widget).startswith(str(self.scrollableDropdown_input_mic_device.frame._parent_frame)) else None, - ) - - ## optionmenu input mic voice language - row +=1 - self.label_input_mic_voice_language = CTkLabel( - self.tabview_config.tab(config_tab_title_transcription), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_input_mic_voice_language.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.optionmenu_input_mic_voice_language = CTkOptionMenu( - self.tabview_config.tab(config_tab_title_transcription), - values=list(transcription_lang.keys()), - command=self.optionmenu_input_mic_voice_language_callback, - variable=StringVar(value=config.INPUT_MIC_VOICE_LANGUAGE), - font=CTkFont(family=config.FONT_FAMILY), - dropdown_font=CTkFont(family=config.FONT_FAMILY), - ) - self.optionmenu_input_mic_voice_language.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - - ## scrollableDropdown input mic voice language - if SCROLLABLE_DROPDOWN: - self.scrollableDropdown_input_voice_language = CTkScrollableDropdown( - self.optionmenu_input_mic_voice_language, - values=list(transcription_lang.keys()), - justify="left", - button_color="transparent", - command=self.optionmenu_input_mic_voice_language_callback, - font=CTkFont(family=config.FONT_FAMILY), - ) - self.scrollableDropdown_input_voice_language.bind( - "", - lambda e: self.scrollableDropdown_input_voice_language._withdraw() if not str(e.widget).startswith(str(self.scrollableDropdown_input_voice_language.frame._parent_frame)) else None, - ) - - ## slider input mic energy threshold - row +=1 - self.label_input_mic_energy_threshold = CTkLabel( - self.tabview_config.tab(config_tab_title_transcription), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_input_mic_energy_threshold.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - - self.slider_input_mic_energy_threshold = CTkSlider( - self.tabview_config.tab(config_tab_title_transcription), - from_=0, - to=config.MAX_MIC_ENERGY_THRESHOLD, - border_width=7, - button_length=0, - button_corner_radius=3, - number_of_steps=config.MAX_MIC_ENERGY_THRESHOLD, - command=self.slider_input_mic_energy_threshold_callback, - variable=IntVar(value=config.INPUT_MIC_ENERGY_THRESHOLD), - ) - self.slider_input_mic_energy_threshold.grid(row=row, column=1, columnspan=1, padx=0, pady=5, sticky="nsew") - - ## progressBar input mic energy threshold - row +=1 - self.checkbox_input_mic_threshold_check = CTkCheckBox( - self.tabview_config.tab(config_tab_title_transcription), - text=init_lang_text, - onvalue=True, - offvalue=False, - command=self.checkbox_input_mic_threshold_check_callback, - font=CTkFont(family=config.FONT_FAMILY) - ) - self.checkbox_input_mic_threshold_check.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - - self.progressBar_input_mic_energy_threshold = CTkProgressBar( - self.tabview_config.tab(config_tab_title_transcription), - corner_radius=0 - ) - self.progressBar_input_mic_energy_threshold.grid(row=row, column=1, columnspan=1, padx=padx, pady=5, sticky="nsew") - self.progressBar_input_mic_energy_threshold.set(0) - - ## checkbox input mic dynamic energy threshold - row +=1 - self.label_input_mic_dynamic_energy_threshold = CTkLabel( - self.tabview_config.tab(config_tab_title_transcription), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_input_mic_dynamic_energy_threshold.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.checkbox_input_mic_dynamic_energy_threshold = CTkCheckBox( - self.tabview_config.tab(config_tab_title_transcription), - text="", - onvalue=True, - offvalue=False, - command=self.checkbox_input_mic_dynamic_energy_threshold_callback, - font=CTkFont(family=config.FONT_FAMILY) - ) - self.checkbox_input_mic_dynamic_energy_threshold.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - if config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD is True: - self.checkbox_input_mic_dynamic_energy_threshold.select() - else: - self.checkbox_input_mic_dynamic_energy_threshold.deselect() - - ## entry input mic record timeout - row +=1 - self.label_input_mic_record_timeout = CTkLabel( - self.tabview_config.tab(config_tab_title_transcription), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_input_mic_record_timeout.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.entry_input_mic_record_timeout = CTkEntry( - self.tabview_config.tab(config_tab_title_transcription), - textvariable=StringVar(value=config.INPUT_MIC_RECORD_TIMEOUT), - font=CTkFont(family=config.FONT_FAMILY) - ) - self.entry_input_mic_record_timeout.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_input_mic_record_timeout.bind("", self.entry_input_mic_record_timeout_callback) - - ## entry input mic phrase timeout - row +=1 - self.label_input_mic_phrase_timeout = CTkLabel( - self.tabview_config.tab(config_tab_title_transcription), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_input_mic_phrase_timeout.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.entry_input_mic_phrase_timeout = CTkEntry( - self.tabview_config.tab(config_tab_title_transcription), - textvariable=StringVar(value=config.INPUT_MIC_PHRASE_TIMEOUT), - font=CTkFont(family=config.FONT_FAMILY) - ) - self.entry_input_mic_phrase_timeout.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_input_mic_phrase_timeout.bind("", self.entry_input_mic_phrase_timeout_callback) - - ## entry input mic max phrases - row +=1 - self.label_input_mic_max_phrases = CTkLabel( - self.tabview_config.tab(config_tab_title_transcription), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_input_mic_max_phrases.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.entry_input_mic_max_phrases = CTkEntry( - self.tabview_config.tab(config_tab_title_transcription), - textvariable=StringVar(value=config.INPUT_MIC_MAX_PHRASES), - font=CTkFont(family=config.FONT_FAMILY) - ) - self.entry_input_mic_max_phrases.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_input_mic_max_phrases.bind("", self.entry_input_mic_max_phrases_callback) - - ## entry input mic word filter - row +=1 - self.label_input_mic_word_filter = CTkLabel( - self.tabview_config.tab(config_tab_title_transcription), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_input_mic_word_filter.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - if len(config.INPUT_MIC_WORD_FILTER) > 0: - textvariable=StringVar(value=",".join(config.INPUT_MIC_WORD_FILTER)) - else: - textvariable=None - self.entry_input_mic_word_filter = CTkEntry( - self.tabview_config.tab(config_tab_title_transcription), - textvariable=textvariable, - placeholder_text="AAA,BBB,CCC", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.entry_input_mic_word_filter.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_input_mic_word_filter.bind("", self.entry_input_mic_word_filters_callback) - - ## optionmenu input speaker device - row +=1 - self.label_input_speaker_device = CTkLabel( - self.tabview_config.tab(config_tab_title_transcription), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_input_speaker_device.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.optionmenu_input_speaker_device = CTkOptionMenu( - self.tabview_config.tab(config_tab_title_transcription), - values=model.getListOutputDevice(), - command=self.optionmenu_input_speaker_device_callback, - variable=StringVar(value=config.CHOICE_SPEAKER_DEVICE), - font=CTkFont(family=config.FONT_FAMILY), - dropdown_font=CTkFont(family=config.FONT_FAMILY), - ) - self.optionmenu_input_speaker_device.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - - ## scrollableDropdown input speaker device - if SCROLLABLE_DROPDOWN: - self.scrollableDropdown_input_speaker_device = CTkScrollableDropdown( - self.optionmenu_input_speaker_device, - values=model.getListOutputDevice(), - justify="left", - button_color="transparent", - command=self.optionmenu_input_speaker_device_callback, - font=CTkFont(family=config.FONT_FAMILY), - ) - self.scrollableDropdown_input_speaker_device.bind( - "", - lambda e: self.scrollableDropdown_input_speaker_device._withdraw() if not str(e.widget).startswith(str(self.scrollableDropdown_input_speaker_device.frame._parent_frame)) else None, - ) - - ## optionmenu input speaker voice language - row +=1 - self.label_input_speaker_voice_language = CTkLabel( - self.tabview_config.tab(config_tab_title_transcription), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_input_speaker_voice_language.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.optionmenu_input_speaker_voice_language = CTkOptionMenu( - self.tabview_config.tab(config_tab_title_transcription), - values=list(transcription_lang.keys()), - command=self.optionmenu_input_speaker_voice_language_callback, - variable=StringVar(value=config.INPUT_SPEAKER_VOICE_LANGUAGE), - font=CTkFont(family=config.FONT_FAMILY), - dropdown_font=CTkFont(family=config.FONT_FAMILY), - ) - self.optionmenu_input_speaker_voice_language.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - - ## scrollableDropdown input speaker voice language - if SCROLLABLE_DROPDOWN: - self.scrollableDropdown_input_speaker_voice_language = CTkScrollableDropdown( - self.optionmenu_input_speaker_voice_language, - values=list(transcription_lang.keys()), - justify="left", - button_color="transparent", - command=self.optionmenu_input_speaker_voice_language_callback, - font=CTkFont(family=config.FONT_FAMILY), - ) - self.scrollableDropdown_input_speaker_voice_language.bind( - "", - lambda e: self.scrollableDropdown_input_speaker_voice_language._withdraw() if not str(e.widget).startswith(str(self.scrollableDropdown_input_speaker_voice_language.frame._parent_frame)) else None, - ) - - ## entry input speaker energy threshold - row +=1 - self.label_input_speaker_energy_threshold = CTkLabel( - self.tabview_config.tab(config_tab_title_transcription), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_input_speaker_energy_threshold.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - - ## progressBar input speaker energy threshold - self.slider_input_speaker_energy_threshold = CTkSlider( - self.tabview_config.tab(config_tab_title_transcription), - from_=0, - to=config.MAX_SPEAKER_ENERGY_THRESHOLD, - border_width=7, - button_length=0, - button_corner_radius=3, - number_of_steps=config.MAX_SPEAKER_ENERGY_THRESHOLD, - command=self.slider_input_speaker_energy_threshold_callback, - variable=IntVar(value=config.INPUT_SPEAKER_ENERGY_THRESHOLD), - ) - self.slider_input_speaker_energy_threshold.grid(row=row, column=1, columnspan=1, padx=0, pady=5, sticky="nsew") - - ## progressBar input speaker energy threshold - row +=1 - self.checkbox_input_speaker_threshold_check = CTkCheckBox( - self.tabview_config.tab(config_tab_title_transcription), - text=init_lang_text, - onvalue=True, - offvalue=False, - command=self.checkbox_input_speaker_threshold_check_callback, - font=CTkFont(family=config.FONT_FAMILY) - ) - self.checkbox_input_speaker_threshold_check.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - - self.progressBar_input_speaker_energy_threshold = CTkProgressBar( - self.tabview_config.tab(config_tab_title_transcription), - corner_radius=0 - ) - self.progressBar_input_speaker_energy_threshold.grid(row=row, column=1, columnspan=1, padx=padx, pady=5, sticky="nsew") - self.progressBar_input_speaker_energy_threshold.set(0) - - ## checkbox input speaker dynamic energy threshold - row +=1 - self.label_input_speaker_dynamic_energy_threshold = CTkLabel( - self.tabview_config.tab(config_tab_title_transcription), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_input_speaker_dynamic_energy_threshold.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.checkbox_input_speaker_dynamic_energy_threshold = CTkCheckBox( - self.tabview_config.tab(config_tab_title_transcription), - text="", - onvalue=True, - offvalue=False, - command=self.checkbox_input_speaker_dynamic_energy_threshold_callback, - font=CTkFont(family=config.FONT_FAMILY) - ) - self.checkbox_input_speaker_dynamic_energy_threshold.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - if config.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD is True: - self.checkbox_input_speaker_dynamic_energy_threshold.select() - else: - self.checkbox_input_speaker_dynamic_energy_threshold.deselect() - - ## entry input speaker record timeout - row +=1 - self.label_input_speaker_record_timeout = CTkLabel( - self.tabview_config.tab(config_tab_title_transcription), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_input_speaker_record_timeout.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.entry_input_speaker_record_timeout = CTkEntry( - self.tabview_config.tab(config_tab_title_transcription), - textvariable=StringVar(value=config.INPUT_SPEAKER_RECORD_TIMEOUT), - font=CTkFont(family=config.FONT_FAMILY) - ) - self.entry_input_speaker_record_timeout.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_input_speaker_record_timeout.bind("", self.entry_input_speaker_record_timeout_callback) - - ## entry input speaker phrase timeout - row +=1 - self.label_input_speaker_phrase_timeout = CTkLabel( - self.tabview_config.tab(config_tab_title_transcription), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_input_speaker_phrase_timeout.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.entry_input_speaker_phrase_timeout = CTkEntry( - self.tabview_config.tab(config_tab_title_transcription), - textvariable=StringVar(value=config.INPUT_SPEAKER_PHRASE_TIMEOUT), - font=CTkFont(family=config.FONT_FAMILY) - ) - self.entry_input_speaker_phrase_timeout.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_input_speaker_phrase_timeout.bind("", self.entry_input_speaker_phrase_timeout_callback) - - ## entry input speaker max phrases - row +=1 - self.label_input_speaker_max_phrases = CTkLabel( - self.tabview_config.tab(config_tab_title_transcription), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_input_speaker_max_phrases.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.entry_input_speaker_max_phrases = CTkEntry( - self.tabview_config.tab(config_tab_title_transcription), - textvariable=StringVar(value=config.INPUT_SPEAKER_MAX_PHRASES), - font=CTkFont(family=config.FONT_FAMILY) - ) - self.entry_input_speaker_max_phrases.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_input_speaker_max_phrases.bind("", self.entry_input_speaker_max_phrases_callback) - - # tab Parameter - ## entry ip address - row = 0 - padx = 5 - pady = 1 - self.label_ip_address = CTkLabel( - self.tabview_config.tab(config_tab_title_parameter), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_ip_address.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.entry_ip_address = CTkEntry( - self.tabview_config.tab(config_tab_title_parameter), - textvariable=StringVar(value=config.OSC_IP_ADDRESS), - font=CTkFont(family=config.FONT_FAMILY) - ) - self.entry_ip_address.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_ip_address.bind("", self.entry_ip_address_callback) - - ## entry port - row +=1 - self.label_port = CTkLabel( - self.tabview_config.tab(config_tab_title_parameter), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_port.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.entry_port = CTkEntry( - self.tabview_config.tab(config_tab_title_parameter), - textvariable=StringVar(value=config.OSC_PORT), - font=CTkFont(family=config.FONT_FAMILY) - ) - self.entry_port.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_port.bind("", self.entry_port_callback) - - ## entry authkey - row +=1 - self.label_authkey = CTkLabel( - self.tabview_config.tab(config_tab_title_parameter), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_authkey.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.entry_authkey = CTkEntry( - self.tabview_config.tab(config_tab_title_parameter), - textvariable=StringVar(value=config.AUTH_KEYS["DeepL(auth)"]), - font=CTkFont(family=config.FONT_FAMILY) - ) - self.entry_authkey.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_authkey.bind("", self.entry_authkey_callback) - - ## entry message format - row +=1 - self.label_message_format = CTkLabel( - self.tabview_config.tab(config_tab_title_parameter), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_message_format.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.entry_message_format = CTkEntry( - self.tabview_config.tab(config_tab_title_parameter), - textvariable=StringVar(value=config.MESSAGE_FORMAT), - font=CTkFont(family=config.FONT_FAMILY) - ) - self.entry_message_format.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_message_format.bind("", self.entry_message_format_callback) - - # tab Others - ## checkbox auto clear chat box - row = 0 - self.label_checkbox_auto_clear_chatbox = CTkLabel( - self.tabview_config.tab(config_tab_title_others), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_checkbox_auto_clear_chatbox.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.checkbox_auto_clear_chatbox = CTkCheckBox( - self.tabview_config.tab(config_tab_title_others), - text="", - onvalue=True, - offvalue=False, - command=self.checkbox_auto_clear_chatbox_callback, - font=CTkFont(family=config.FONT_FAMILY) - ) - self.checkbox_auto_clear_chatbox.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - if config.ENABLE_AUTO_CLEAR_CHATBOX is True: - self.checkbox_auto_clear_chatbox.select() - else: - self.checkbox_auto_clear_chatbox.deselect() - - # checkbox notice xsoverlay - row += 1 - self.label_checkbox_notice_xsoverlay = CTkLabel( - self.tabview_config.tab(config_tab_title_others), - text=init_lang_text, - fg_color="transparent", - font=CTkFont(family=config.FONT_FAMILY) - ) - self.label_checkbox_notice_xsoverlay.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.checkbox_notice_xsoverlay = CTkCheckBox( - self.tabview_config.tab(config_tab_title_others), - text="", - onvalue=True, - offvalue=False, - command=self.checkbox_notice_xsoverlay_callback, - font=CTkFont(family=config.FONT_FAMILY) - ) - self.checkbox_notice_xsoverlay.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - if config.ENABLE_NOTICE_XSOVERLAY is True: - self.checkbox_notice_xsoverlay.select() - else: - self.checkbox_notice_xsoverlay.deselect() - widget_config_window_label_setter(self, language_yaml_data) \ No newline at end of file diff --git a/window_information.py b/window_information.py deleted file mode 100644 index cc8d8792..00000000 --- a/window_information.py +++ /dev/null @@ -1,161 +0,0 @@ -import os -from customtkinter import CTkToplevel, CTkTextbox, CTkFont -from config import config - -class ToplevelWindowInformation(CTkToplevel): - def __init__(self, parent, *args, **kwargs): - super().__init__(parent, *args, **kwargs) - self.withdraw() - self.parent = parent - self.grid_columnconfigure(0, weight=1) - self.grid_rowconfigure(0, weight=1) - # self.geometry(f"{500}x{300}") - self.minsize(500, 300) - - self.after(200, lambda: self.iconbitmap(os.path.join(os.path.dirname(__file__), "img", "app.ico"))) - self.title("Information") - # create textbox information - self.textbox_information = CTkTextbox( - self, - font=CTkFont(family=config.FONT_FAMILY) - ) - self.textbox_information.grid(row=0, column=0, padx=(10, 10), pady=(10, 10), sticky="nsew") - textbox_information_message = """VRCT(v1.3.2) - -# 概要 -VRChatで使用されるChatBoxをOSC経由でメッセージを送信するツールになります。 -翻訳エンジンを使用してメッセージとその翻訳部分を同時に送信することができます。 -(翻訳エンジンはDeepL,Google,Bingに対応) - -# 使用方法 - 初期設定時 - 0. VRChatのOSCを有効にする(重要) - - (任意) - 1. DeepLのAPIを使用するためにアカウント登録し、認証キーを取得する - 2. ギアアイコンのボタンでconfigウィンドウを開く - 3. ParameterタブのDeepL Auth Keyに認証キーを記載 - 4. configウィンドウを閉じる - - 通常使用時 - 1. メッセージボックスにメッセージを記入 - 2. Enterキーを押し、メッセージを送信する - -# その他の設定 - translation チェックボックス: 翻訳の有効無効 - voice2chatbox チェックボックス : マイクの音声を文字起こししてチャットボックスに送信する - speaker2log チェックボックス : スピーカーの音声から文字起こししてログに表示する - foreground チェックボックス: 最前面表示の有効無効 - - テキストボックス - logタブ - すべてのログを表示 - sendタブ - 送信したメッセージを表示 - receiveタブ - 受信したメッセージを表示 - systemタブ - 機能についてのメッセージを表示 - - configウィンドウ - UIタブ - Transparency: ウィンドウの透過度の調整 - Appearance Theme: ウィンドウテーマを選択 - UI Scaling: UIサイズを調整 - Font Family: 表示フォントを選択 - UI Language: UIの表示言語を選択 - Translationタブ - Select Translator: 翻訳エンジンの変更 - Send Language: 送信するメッセージに対して翻訳する言語[source, target]を選択 - Receive Language: 受信したメッセージに対して翻訳する言語[source, target]を選択 - Transcriptionタブ - Input Mic Host: マイクのホストAPIを選択 - Input Mic Device: マイクを選択 - Input Mic Voice Language: 入力する音声の言語 - Input Mic Energy Threshold: 音声取得のしきい値 - Check threshold point: Input Mic Energy Thresholdのしきい値を視覚化 - Input Mic Dynamic Energy Threshold: 音声取得のしきい値の自動調整 - Input Mic Record Timeout: 音声の区切りの無音時間 - Input Mic Phase Timeout: 文字起こしする音声時間の上限 - Input Mic Max Phrases: 保留する単語の上限 - Input Mic Word Filter: MICの文字起こし時にWord Filterで設定した文字が入っていた場合にChatboxに表示しない (ex AAA,BBB,CCC) - Input Speaker Device: スピーカーを選択 - Input Speaker Voice Language: 受信する音声の言語 - Input Speaker Energy Threshold: 音声取得のしきい値 - Check threshold point: Input Speaker Energy Thresholdのしきい値を視覚化 - Input Speaker Dynamic Energy Threshold: 音声取得のしきい値の自動調整 - Input Speaker Record Timeout: 音声の区切りの無音時間 - Input Speaker Phase Timeout: 文字起こしする音声時間の上限 - Input Speaker Max Phrases: 保留する単語の上限 - Parameterタブ - OSC IP address: 変更不要 - OSC port: 変更不要 - DeepL Auth key: DeepLの認証キーの設定 - Message Format: 送信するメッセージのデコレーションの設定 - [message]がメッセージボックスに記入したメッセージに置換される - [translation]が翻訳されたメッセージに置換される - 初期フォーマット:"[message]([translation])" - Othersタブ - Auto clear chat box: メッセージ送信後に書き込んだメッセージを空にする - (New!) Notification XSOverlay: XSOverlayの通知機能を有効(VR only) - - 設定の初期化 - config.jsonを削除 - -# お問い合わせ -要望などはTwitterまで -https://twitter.com/misya_ai - -# アップデート履歴 -[2023-05-29: v0.1b] v0.1b リリース -[2023-05-30: v0.2b] -- configボタンをギアアイコンに変更 -- 詳細情報のボタンを追加 -- 翻訳機能有効無効のチェックボックスを追加 -- 最前面表示の有効無効のチェックボックスを追加 -- いくつかのバグを修正 -[2023-06-03: v0.3b] -- 全体的にUIを刷新 -- 透過機能を追加 -- テーマのLight/Dark/Systemのモードの変更機能を追加 -- UIのスケール変更機能を追加 -- フォントの変更機能を追加 -[2023-06-06: v0.4b] -- 翻訳エンジンを追加 -- 入力と出力の翻訳言語を選択できるように変更 -[2023-06-20: v1.0] -- マイクからの音声の文字起こし機能を追加 -- スピーカーからの音声の文字起こし機能を追加 -[2023-06-28: v1.1] -- いくつかのバクを修正 -- 翻訳/文字起こし言語の表記を略称からわかりやすい文字に変更 -- 文字起こしの処理の軽量化 -[2023-07-05: v1.2] -- 文字起こし精度の向上 -[2023-07-21: v1.3] -- UIの表示言語を日本語/英語を選択できる機能を追加 -- Energy Thresholdの視覚化機能を追加 -- 文字起こしの誤認識対策のため、Word Filterを追加 -- WASAPI以外のHostAPIでもマイクとして使用できるようにHostAPIを選択できる機能を追加 -- メッセージ送信後に書き込んだメッセージを空にするか選択できる機能を追加 -- バグ対策のため、translation/voice2chatbox/speaker2log/foregroundは起動時はOFFになるように変更 -- バグ対策のため、スピーカーについて既定デバイス以外を選択した時にERRORが出るように変更 -- 半角入力時に一部の文字が書き込めないバグを修正 -[2023-07-22: v1.3.1] -- UIの表示言語選択に韓国語を追加 -[2023-07-30: v1.3.2] -- 試験的にXSOverlayへの通知機能を追加 -- checkbox ONの状態でもConfigを開けるように変更 -- 文字起こし言語の表示を修正 -- いくつかのバグを修正 - -# 注意事項 -再配布とかはやめてね -""" - - self.textbox_information.insert("end", textbox_information_message) - self.textbox_information.configure(state='disabled') - self.protocol("WM_DELETE_WINDOW", self.delete_window) - - def delete_window(self): - self.withdraw() \ No newline at end of file