From 1231fbd83c56fcef6306670cccb2bc909712f34a Mon Sep 17 00:00:00 2001 From: misygauziya Date: Tue, 15 Aug 2023 11:45:37 +0900 Subject: [PATCH] =?UTF-8?q?[Update]=20config.py=E3=81=AE=E8=A8=AD=E5=AE=9A?= =?UTF-8?q?=E3=82=92=E4=BB=96=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=AB?= =?UTF-8?q?=E9=81=A9=E5=BF=9C=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VRCT.py | 346 ++++++----------------------------- config.py | 25 +-- window_config.py | 413 +++++++++++++++++++----------------------- window_information.py | 3 +- 4 files changed, 245 insertions(+), 542 deletions(-) diff --git a/VRCT.py b/VRCT.py index a3c93ec9..d52398eb 100644 --- a/VRCT.py +++ b/VRCT.py @@ -1,10 +1,7 @@ from time import sleep from os import path as os_path -from json import load as json_load -from json import dump as json_dump from requests import get as requests_get from queue import Queue -import tkinter as tk import customtkinter from customtkinter import CTk, CTkFrame, CTkCheckBox, CTkFont, CTkButton, CTkImage, CTkTabview, CTkTextbox, CTkEntry from PIL.Image import open as Image_open @@ -15,11 +12,12 @@ from utils import print_textbox, thread_fnc, get_localized_text, widget_main_win from osc_tools import send_typing, send_message, send_test_action, receive_osc_parameters from window_config import ToplevelWindowConfig from window_information import ToplevelWindowInformation -from languages import transcription_lang, translators, translation_lang, selectable_languages -from audio_utils import get_input_device_list, get_output_device_list, get_default_input_device, get_default_output_device +from languages import transcription_lang +from audio_utils import get_input_device_list, get_output_device_list from audio_recorder import SelectedMicRecorder, SelectedSpeakerRecorder from audio_transcriber import AudioTranscriber from translation import Translator +from config import config from notification import notification_xsoverlay_for_vrct __version__ = "1.3.2" @@ -32,238 +30,14 @@ class App(CTk): self.translator = Translator() self.keyword_processor = KeywordProcessor() - # init config - self.PATH_CONFIG = "./config.json" - - ## main window - # self.ENABLE_TRANSLATION = False - # self.ENABLE_TRANSCRIPTION_SEND = False - # self.ENABLE_TRANSCRIPTION_RECEIVE = False - # self.ENABLE_FOREGROUND = False - - ## UI - self.TRANSPARENCY = 100 - self.APPEARANCE_THEME = "System" - self.UI_SCALING = "100%" - self.FONT_FAMILY = "Yu Gothic UI" - self.UI_LANGUAGE = "en" - ## Translation - self.CHOICE_TRANSLATOR = translators[0] - self.INPUT_SOURCE_LANG = list(translation_lang[self.CHOICE_TRANSLATOR]["source"].keys())[0] - self.INPUT_TARGET_LANG = list(translation_lang[self.CHOICE_TRANSLATOR]["target"].keys())[1] - self.OUTPUT_SOURCE_LANG = list(translation_lang[self.CHOICE_TRANSLATOR]["source"].keys())[1] - self.OUTPUT_TARGET_LANG = list(translation_lang[self.CHOICE_TRANSLATOR]["target"].keys())[0] - ## Transcription Send - self.CHOICE_MIC_HOST = get_default_input_device()["host"]["name"] - self.CHOICE_MIC_DEVICE = get_default_input_device()["device"]["name"] - self.INPUT_MIC_VOICE_LANGUAGE = list(transcription_lang.keys())[0] - self.INPUT_MIC_ENERGY_THRESHOLD = 300 - self.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD = True - self.INPUT_MIC_RECORD_TIMEOUT = 3 - self.INPUT_MIC_PHRASE_TIMEOUT = 3 - self.INPUT_MIC_MAX_PHRASES = 10 - self.INPUT_MIC_WORD_FILTER = [] - ## Transcription Receive - self.CHOICE_SPEAKER_DEVICE = get_default_output_device()["name"] - self.INPUT_SPEAKER_VOICE_LANGUAGE = list(transcription_lang.keys())[1] - self.INPUT_SPEAKER_ENERGY_THRESHOLD = 300 - self.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = True - self.INPUT_SPEAKER_RECORD_TIMEOUT = 3 - self.INPUT_SPEAKER_PHRASE_TIMEOUT = 3 - self.INPUT_SPEAKER_MAX_PHRASES = 10 - - ## Parameter - self.OSC_IP_ADDRESS = "127.0.0.1" - self.OSC_PORT = 9000 - self.AUTH_KEYS = { - "DeepL(web)": None, - "DeepL(auth)": None, - "Bing(web)": None, - "Google(web)": None, - } - self.MESSAGE_FORMAT = "[message]([translation])" - # Others - self.ENABLE_AUTO_CLEAR_CHATBOX = False - self.ENABLE_OSC = False - self.ENABLE_NOTICE_XSOVERLAY =False - self.UPDATE_FLAG = False - - # load config - if os_path.isfile(self.PATH_CONFIG) is not False: - with open(self.PATH_CONFIG, 'r') as fp: - config = json_load(fp) - # main window - # main windowは初期はすべてOFFにする - # if "ENABLE_TRANSLATION" in config.keys(): - # if type(config["ENABLE_TRANSLATION"]) is bool: - # self.ENABLE_TRANSLATION = config["ENABLE_TRANSLATION"] - - # 環境に依ってマイクとスピーカーを同時起動するとエラーが発生するため、起動時は強制的にOFFにする - # if "ENABLE_TRANSCRIPTION_SEND" in config.keys(): - # if type(config["ENABLE_TRANSCRIPTION_SEND"]) is bool: - # self.ENABLE_TRANSCRIPTION_SEND = config["ENABLE_TRANSCRIPTION_SEND"] - # if "ENABLE_TRANSCRIPTION_RECEIVE" in config.keys(): - # if type(config["ENABLE_TRANSCRIPTION_RECEIVE"]) is bool: - # self.ENABLE_TRANSCRIPTION_RECEIVE = config["ENABLE_TRANSCRIPTION_RECEIVE"] - - # if "ENABLE_FOREGROUND" in config.keys(): - # if type(config["ENABLE_FOREGROUND"]) is bool: - # self.ENABLE_FOREGROUND = config["ENABLE_FOREGROUND"] - - # tab ui - if "TRANSPARENCY" in config.keys(): - if type(config["TRANSPARENCY"]) is int: - if 0 <= config["TRANSPARENCY"] <= 100: - self.TRANSPARENCY = config["TRANSPARENCY"] - if "APPEARANCE_THEME" in config.keys(): - if config["APPEARANCE_THEME"] in ["Light", "Dark", "System"]: - self.APPEARANCE_THEME = config["APPEARANCE_THEME"] - if "UI_SCALING" in config.keys(): - if config["UI_SCALING"] in ["80%", "90%", "100%", "110%", "120%"]: - self.UI_SCALING = config["UI_SCALING"] - if "FONT_FAMILY" in config.keys(): - if config["FONT_FAMILY"] in list(tk.font.families()): - self.FONT_FAMILY = config["FONT_FAMILY"] - if "UI_LANGUAGE" in config.keys(): - if config["UI_LANGUAGE"] in list(selectable_languages.keys()): - self.UI_LANGUAGE = config["UI_LANGUAGE"] - - # translation - if "CHOICE_TRANSLATOR" in config.keys(): - if config["CHOICE_TRANSLATOR"] in list(self.translator.translator_status.keys()): - self.CHOICE_TRANSLATOR = config["CHOICE_TRANSLATOR"] - if "INPUT_SOURCE_LANG" in config.keys(): - if config["INPUT_SOURCE_LANG"] in list(translation_lang[self.CHOICE_TRANSLATOR]["source"].keys()): - self.INPUT_SOURCE_LANG = config["INPUT_SOURCE_LANG"] - if "INPUT_TARGET_LANG" in config.keys(): - if config["INPUT_TARGET_LANG"] in list(translation_lang[self.CHOICE_TRANSLATOR]["target"].keys()): - self.INPUT_TARGET_LANG = config["INPUT_TARGET_LANG"] - if "OUTPUT_SOURCE_LANG" in config.keys(): - if config["OUTPUT_SOURCE_LANG"] in list(translation_lang[self.CHOICE_TRANSLATOR]["source"].keys()): - self.OUTPUT_SOURCE_LANG = config["OUTPUT_SOURCE_LANG"] - if "OUTPUT_TARGET_LANG" in config.keys(): - if config["OUTPUT_TARGET_LANG"] in list(translation_lang[self.CHOICE_TRANSLATOR]["target"].keys()): - self.OUTPUT_TARGET_LANG = config["OUTPUT_TARGET_LANG"] - - # Transcription - if "CHOICE_MIC_HOST" in config.keys(): - if config["CHOICE_MIC_HOST"] in [host for host in get_input_device_list().keys()]: - self.CHOICE_MIC_HOST = config["CHOICE_MIC_HOST"] - if "CHOICE_MIC_DEVICE" in config.keys(): - if config["CHOICE_MIC_DEVICE"] in [device["name"] for device in get_input_device_list()[self.CHOICE_MIC_HOST]]: - self.CHOICE_MIC_DEVICE = config["CHOICE_MIC_DEVICE"] - if "INPUT_MIC_VOICE_LANGUAGE" in config.keys(): - if config["INPUT_MIC_VOICE_LANGUAGE"] in list(transcription_lang.keys()): - self.INPUT_MIC_VOICE_LANGUAGE = config["INPUT_MIC_VOICE_LANGUAGE"] - if "INPUT_MIC_ENERGY_THRESHOLD" in config.keys(): - if type(config["INPUT_MIC_ENERGY_THRESHOLD"]) is int: - self.INPUT_MIC_ENERGY_THRESHOLD = config["INPUT_MIC_ENERGY_THRESHOLD"] - if "INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD" in config.keys(): - if type(config["INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD"]) is bool: - self.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD = config["INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD"] - if "INPUT_MIC_RECORD_TIMEOUT" in config.keys(): - if type(config["INPUT_MIC_RECORD_TIMEOUT"]) is int: - self.INPUT_MIC_RECORD_TIMEOUT = config["INPUT_MIC_RECORD_TIMEOUT"] - if "INPUT_MIC_PHRASE_TIMEOUT" in config.keys(): - if type(config["INPUT_MIC_PHRASE_TIMEOUT"]) is int: - self.INPUT_MIC_PHRASE_TIMEOUT = config["INPUT_MIC_PHRASE_TIMEOUT"] - if "INPUT_MIC_MAX_PHRASES" in config.keys(): - if type(config["INPUT_MIC_MAX_PHRASES"]) is int: - self.INPUT_MIC_MAX_PHRASES = config["INPUT_MIC_MAX_PHRASES"] - if "INPUT_MIC_WORD_FILTER" in config.keys(): - if type(config["INPUT_MIC_WORD_FILTER"]) is list: - self.INPUT_MIC_WORD_FILTER = config["INPUT_MIC_WORD_FILTER"] - - if "CHOICE_SPEAKER_DEVICE" in config.keys(): - if config["CHOICE_SPEAKER_DEVICE"] in [device["name"] for device in get_output_device_list()]: - speaker_device = [device for device in get_output_device_list() if device["name"] == config["CHOICE_SPEAKER_DEVICE"]][0] - if get_default_output_device()["index"] == speaker_device["index"]: - self.CHOICE_SPEAKER_DEVICE = config["CHOICE_SPEAKER_DEVICE"] - if "INPUT_SPEAKER_VOICE_LANGUAGE" in config.keys(): - if config["INPUT_SPEAKER_VOICE_LANGUAGE"] in list(transcription_lang.keys()): - self.INPUT_SPEAKER_VOICE_LANGUAGE = config["INPUT_SPEAKER_VOICE_LANGUAGE"] - if "INPUT_SPEAKER_ENERGY_THRESHOLD" in config.keys(): - if type(config["INPUT_SPEAKER_ENERGY_THRESHOLD"]) is int: - self.INPUT_SPEAKER_ENERGY_THRESHOLD = config["INPUT_SPEAKER_ENERGY_THRESHOLD"] - if "INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD" in config.keys(): - if type(config["INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD"]) is bool: - self.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = config["INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD"] - if "INPUT_SPEAKER_RECORD_TIMEOUT" in config.keys(): - if type(config["INPUT_SPEAKER_RECORD_TIMEOUT"]) is int: - self.INPUT_SPEAKER_RECORD_TIMEOUT = config["INPUT_SPEAKER_RECORD_TIMEOUT"] - if "INPUT_SPEAKER_PHRASE_TIMEOUT" in config.keys(): - if type(config["INPUT_SPEAKER_PHRASE_TIMEOUT"]) is int: - self.INPUT_SPEAKER_PHRASE_TIMEOUT = config["INPUT_SPEAKER_PHRASE_TIMEOUT"] - if "INPUT_SPEAKER_MAX_PHRASES" in config.keys(): - if type(config["INPUT_SPEAKER_MAX_PHRASES"]) is int: - self.INPUT_MIC_MAX_PHRASES = config["INPUT_SPEAKER_MAX_PHRASES"] - - # Parameter - if "OSC_IP_ADDRESS" in config.keys(): - if type(config["OSC_IP_ADDRESS"]) is str: - self.OSC_IP_ADDRESS = config["OSC_IP_ADDRESS"] - if "OSC_PORT" in config.keys(): - if type(config["OSC_PORT"]) is int: - self.OSC_PORT = config["OSC_PORT"] - if "AUTH_KEYS" in config.keys(): - if type(config["AUTH_KEYS"]) is dict: - if set(config["AUTH_KEYS"].keys()) == set(self.AUTH_KEYS.keys()): - for key, value in config["AUTH_KEYS"].items(): - if type(value) is str: - self.AUTH_KEYS[key] = config["AUTH_KEYS"][key] - if "MESSAGE_FORMAT" in config.keys(): - if type(config["MESSAGE_FORMAT"]) is str: - self.MESSAGE_FORMAT = config["MESSAGE_FORMAT"] - - # Others - if "ENABLE_AUTO_CLEAR_CHATBOX" in config.keys(): - if type(config["ENABLE_AUTO_CLEAR_CHATBOX"]) is bool: - self.ENABLE_AUTO_CLEAR_CHATBOX = config["ENABLE_AUTO_CLEAR_CHATBOX"] - if "ENABLE_NOTICE_XSOVERLAY" in config.keys(): - if type(config["ENABLE_NOTICE_XSOVERLAY"]) is bool: - self.ENABLE_NOTICE_XSOVERLAY = config["ENABLE_NOTICE_XSOVERLAY"] - - with open(self.PATH_CONFIG, 'w') as fp: - config = { - "TRANSPARENCY": self.TRANSPARENCY, - "APPEARANCE_THEME": self.APPEARANCE_THEME, - "UI_SCALING": self.UI_SCALING, - "UI_LANGUAGE": self.UI_LANGUAGE, - "FONT_FAMILY": self.FONT_FAMILY, - "CHOICE_TRANSLATOR": self.CHOICE_TRANSLATOR, - "INPUT_SOURCE_LANG": self.INPUT_SOURCE_LANG, - "INPUT_TARGET_LANG": self.INPUT_TARGET_LANG, - "OUTPUT_SOURCE_LANG": self.OUTPUT_SOURCE_LANG, - "OUTPUT_TARGET_LANG": self.OUTPUT_TARGET_LANG, - "CHOICE_MIC_HOST": self.CHOICE_MIC_HOST, - "CHOICE_MIC_DEVICE": self.CHOICE_MIC_DEVICE, - "INPUT_MIC_VOICE_LANGUAGE": self.INPUT_MIC_VOICE_LANGUAGE, - "INPUT_MIC_ENERGY_THRESHOLD": self.INPUT_MIC_ENERGY_THRESHOLD, - "INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD": self.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD, - "INPUT_MIC_RECORD_TIMEOUT": self.INPUT_MIC_RECORD_TIMEOUT, - "INPUT_MIC_PHRASE_TIMEOUT": self.INPUT_MIC_PHRASE_TIMEOUT, - "INPUT_MIC_MAX_PHRASES": self.INPUT_MIC_MAX_PHRASES, - "INPUT_MIC_WORD_FILTER": self.INPUT_MIC_WORD_FILTER, - "CHOICE_SPEAKER_DEVICE": self.CHOICE_SPEAKER_DEVICE, - "INPUT_SPEAKER_VOICE_LANGUAGE": self.INPUT_SPEAKER_VOICE_LANGUAGE, - "INPUT_SPEAKER_ENERGY_THRESHOLD": self.INPUT_SPEAKER_ENERGY_THRESHOLD, - "INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD": self.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD, - "INPUT_SPEAKER_RECORD_TIMEOUT": self.INPUT_SPEAKER_RECORD_TIMEOUT, - "INPUT_SPEAKER_PHRASE_TIMEOUT": self.INPUT_SPEAKER_PHRASE_TIMEOUT, - "INPUT_SPEAKER_MAX_PHRASES": self.INPUT_SPEAKER_MAX_PHRASES, - "OSC_IP_ADDRESS": self.OSC_IP_ADDRESS, - "OSC_PORT": self.OSC_PORT, - "AUTH_KEYS": self.AUTH_KEYS, - "MESSAGE_FORMAT": self.MESSAGE_FORMAT, - "ENABLE_AUTO_CLEAR_CHATBOX": self.ENABLE_AUTO_CLEAR_CHATBOX, - "ENABLE_NOTICE_XSOVERLAY": self.ENABLE_NOTICE_XSOVERLAY, - } - json_dump(config, fp, indent=4) - ## set UI theme - customtkinter.set_appearance_mode(self.APPEARANCE_THEME) + customtkinter.set_appearance_mode(config.APPEARANCE_THEME) customtkinter.set_default_color_theme("blue") + ## flags + self.ENABLE_OSC = False + self.UPDATE_FLAG = False + # init main window self.iconbitmap(os_path.join(os_path.dirname(__file__), "img", "app.ico")) self.title("VRCT") @@ -286,7 +60,7 @@ class App(CTk): onvalue=True, offvalue=False, command=self.checkbox_translation_callback, - font=CTkFont(family=self.FONT_FAMILY) + font=CTkFont(family=config.FONT_FAMILY) ) self.checkbox_translation.grid(row=0, column=0, columnspan=2, padx=10, pady=(5, 5), sticky="we") @@ -297,7 +71,7 @@ class App(CTk): onvalue=True, offvalue=False, command=self.checkbox_transcription_send_callback, - font=CTkFont(family=self.FONT_FAMILY) + font=CTkFont(family=config.FONT_FAMILY) ) self.checkbox_transcription_send.grid(row=1, column=0, columnspan=2, padx=10, pady=(5, 5), sticky="we") @@ -308,7 +82,7 @@ class App(CTk): onvalue=True, offvalue=False, command=self.checkbox_transcription_receive_callback, - font=CTkFont(family=self.FONT_FAMILY) + font=CTkFont(family=config.FONT_FAMILY) ) self.checkbox_transcription_receive.grid(row=2, column=0, columnspan=2, padx=10, pady=(5, 5), sticky="we") @@ -319,7 +93,7 @@ class App(CTk): onvalue=True, offvalue=False, command=self.checkbox_foreground_callback, - font=CTkFont(family=self.FONT_FAMILY) + font=CTkFont(family=config.FONT_FAMILY) ) self.checkbox_foreground.grid(row=3, column=0, columnspan=2, padx=10, pady=(5, 5), sticky="we") @@ -344,7 +118,7 @@ class App(CTk): self.button_config.grid(row=5, column=1, padx=(5, 10), pady=(5, 5), sticky="wse") # load ui language data - language_yaml_data = get_localized_text(f"{self.UI_LANGUAGE}") + language_yaml_data = get_localized_text(f"{config.UI_LANGUAGE}") # add tabview textbox self.add_tabview_logs(language_yaml_data) @@ -352,13 +126,13 @@ class App(CTk): self.entry_message_box = CTkEntry( self, placeholder_text="message", - font=CTkFont(family=self.FONT_FAMILY), + font=CTkFont(family=config.FONT_FAMILY), ) self.entry_message_box.grid(row=1, column=1, columnspan=2, padx=5, pady=(5, 10), sticky="nsew") # set default values ## set translator - if self.translator.authentication(self.CHOICE_TRANSLATOR, self.AUTH_KEYS[self.CHOICE_TRANSLATOR]) is False: + if self.translator.authentication(config.CHOICE_TRANSLATOR, config.AUTH_KEYS[config.CHOICE_TRANSLATOR]) is False: # error update Auth key print_textbox(self.textbox_message_log, "Auth Key or language setting is incorrect", "ERROR") print_textbox(self.textbox_message_system_log, "Auth Key or language setting is incorrect", "ERROR") @@ -392,7 +166,7 @@ class App(CTk): # self.checkbox_foreground.deselect() ## set word filter - for f in self.INPUT_MIC_WORD_FILTER: + for f in config.INPUT_MIC_WORD_FILTER: self.keyword_processor.add_keyword(f) ## set bind entry message box @@ -401,10 +175,10 @@ class App(CTk): self.entry_message_box.bind("", self.entry_message_box_leave) ## set transparency for main window - self.wm_attributes("-alpha", self.TRANSPARENCY/100) + self.wm_attributes("-alpha", config.TRANSPARENCY/100) ## set UI scale - new_scaling_float = int(self.UI_SCALING.replace("%", "")) / 100 + new_scaling_float = int(config.UI_SCALING.replace("%", "")) / 100 customtkinter.set_widget_scaling(new_scaling_float) # delete window @@ -462,22 +236,22 @@ class App(CTk): def transcription_send_start(self): self.mic_audio_queue = Queue() - mic_device = [device for device in get_input_device_list()[self.CHOICE_MIC_HOST] if device["name"] == self.CHOICE_MIC_DEVICE][0] + mic_device = [device for device in get_input_device_list()[config.CHOICE_MIC_HOST] if device["name"] == config.CHOICE_MIC_DEVICE][0] self.mic_audio_recorder = SelectedMicRecorder( mic_device, - self.INPUT_MIC_ENERGY_THRESHOLD, - self.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD, - self.INPUT_MIC_RECORD_TIMEOUT, + config.INPUT_MIC_ENERGY_THRESHOLD, + config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD, + config.INPUT_MIC_RECORD_TIMEOUT, ) self.mic_audio_recorder.record_into_queue(self.mic_audio_queue) self.mic_transcriber = AudioTranscriber( speaker=False, source=self.mic_audio_recorder.source, - phrase_timeout=self.INPUT_MIC_PHRASE_TIMEOUT, - max_phrases=self.INPUT_MIC_MAX_PHRASES, + phrase_timeout=config.INPUT_MIC_PHRASE_TIMEOUT, + max_phrases=config.INPUT_MIC_MAX_PHRASES, ) def mic_transcript_to_chatbox(): - self.mic_transcriber.transcribe_audio_queue(self.mic_audio_queue, transcription_lang[self.INPUT_MIC_VOICE_LANGUAGE]) + self.mic_transcriber.transcribe_audio_queue(self.mic_audio_queue, transcription_lang[config.INPUT_MIC_VOICE_LANGUAGE]) message = self.mic_transcriber.get_transcript() if len(message) > 0: # word filter @@ -489,23 +263,23 @@ class App(CTk): # translate if self.checkbox_translation.get() is False: voice_message = f"{message}" - elif self.translator.translator_status[self.CHOICE_TRANSLATOR] is False: + elif self.translator.translator_status[config.CHOICE_TRANSLATOR] is False: print_textbox(self.textbox_message_log, "Auth Key or language setting is incorrect", "ERROR") print_textbox(self.textbox_message_system_log, "Auth Key or language setting is incorrect", "ERROR") voice_message = f"{message}" else: result = self.translator.translate( - translator_name=self.CHOICE_TRANSLATOR, - source_language=self.INPUT_SOURCE_LANG, - target_language=self.INPUT_TARGET_LANG, + translator_name=config.CHOICE_TRANSLATOR, + source_language=config.INPUT_SOURCE_LANG, + target_language=config.INPUT_TARGET_LANG, message=message ) - voice_message = self.MESSAGE_FORMAT.replace("[message]", message).replace("[translation]", result) + voice_message = config.MESSAGE_FORMAT.replace("[message]", message).replace("[translation]", result) if self.checkbox_transcription_send.get() is True: if self.ENABLE_OSC is True: # send OSC message - send_message(voice_message, self.OSC_IP_ADDRESS, self.OSC_PORT) + send_message(voice_message, config.OSC_IP_ADDRESS, config.OSC_PORT) else: print_textbox(self.textbox_message_log, "OSC is not enabled, please enable OSC and rejoin.", "ERROR") print_textbox(self.textbox_message_system_log, "OSC is not enabled, please enable OSC and rejoin.", "ERROR") @@ -560,48 +334,48 @@ class App(CTk): def transcription_receive_start(self): self.spk_audio_queue = Queue() - spk_device = [device for device in get_output_device_list() if device["name"] == self.CHOICE_SPEAKER_DEVICE][0] + spk_device = [device for device in get_output_device_list() if device["name"] == config.CHOICE_SPEAKER_DEVICE][0] self.spk_audio_recorder = SelectedSpeakerRecorder( spk_device, - self.INPUT_SPEAKER_ENERGY_THRESHOLD, - self.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD, - self.INPUT_SPEAKER_RECORD_TIMEOUT, + config.INPUT_SPEAKER_ENERGY_THRESHOLD, + config.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD, + config.INPUT_SPEAKER_RECORD_TIMEOUT, ) self.spk_audio_recorder.record_into_queue(self.spk_audio_queue) self.spk_transcriber = AudioTranscriber( speaker=True, source=self.spk_audio_recorder.source, - phrase_timeout=self.INPUT_SPEAKER_PHRASE_TIMEOUT, - max_phrases=self.INPUT_SPEAKER_MAX_PHRASES, + phrase_timeout=config.INPUT_SPEAKER_PHRASE_TIMEOUT, + max_phrases=config.INPUT_SPEAKER_MAX_PHRASES, ) def spk_transcript_to_textbox(): - self.spk_transcriber.transcribe_audio_queue(self.spk_audio_queue, transcription_lang[self.INPUT_SPEAKER_VOICE_LANGUAGE]) + self.spk_transcriber.transcribe_audio_queue(self.spk_audio_queue, transcription_lang[config.INPUT_SPEAKER_VOICE_LANGUAGE]) message = self.spk_transcriber.get_transcript() if len(message) > 0: # translate if self.checkbox_translation.get() is False: voice_message = f"{message}" - elif self.translator.translator_status[self.CHOICE_TRANSLATOR] is False: + elif self.translator.translator_status[config.CHOICE_TRANSLATOR] is False: print_textbox(self.textbox_message_log, "Auth Key or language setting is incorrect", "ERROR") print_textbox(self.textbox_message_system_log, "Auth Key or language setting is incorrect", "ERROR") voice_message = f"{message}" else: result = self.translator.translate( - translator_name=self.CHOICE_TRANSLATOR, - source_language=self.OUTPUT_SOURCE_LANG, - target_language=self.OUTPUT_TARGET_LANG, + translator_name=config.CHOICE_TRANSLATOR, + source_language=config.OUTPUT_SOURCE_LANG, + target_language=config.OUTPUT_TARGET_LANG, message=message ) - voice_message = self.MESSAGE_FORMAT.replace("[message]", message).replace("[translation]", result) + voice_message = config.MESSAGE_FORMAT.replace("[message]", message).replace("[translation]", result) # send OSC message - # send_message(voice_message, self.OSC_IP_ADDRESS, self.OSC_PORT) + # send_message(voice_message, config.OSC_IP_ADDRESS, self.OSC_PORT) if self.checkbox_transcription_receive.get() is True: # update textbox message receive log print_textbox(self.textbox_message_log, f"{voice_message}", "RECEIVE") print_textbox(self.textbox_message_receive_log, f"{voice_message}", "RECEIVE") - if self.ENABLE_NOTICE_XSOVERLAY is True: + if config.ENABLE_NOTICE_XSOVERLAY is True: notification_xsoverlay_for_vrct(content=f"{voice_message}") self.spk_print_transcript = thread_fnc(spk_transcript_to_textbox) @@ -694,7 +468,7 @@ class App(CTk): def entry_message_box_press_key_enter(self, event): # send OSC typing - send_typing(False, self.OSC_IP_ADDRESS, self.OSC_PORT) + send_typing(False, config.OSC_IP_ADDRESS, config.OSC_PORT) if self.checkbox_foreground.get(): self.attributes("-topmost", True) @@ -704,22 +478,22 @@ class App(CTk): # translate if self.checkbox_translation.get() is False: chat_message = f"{message}" - elif self.translator.translator_status[self.CHOICE_TRANSLATOR] is False: + elif self.translator.translator_status[config.CHOICE_TRANSLATOR] is False: print_textbox(self.textbox_message_log, "Auth Key or language setting is incorrect", "ERROR") print_textbox(self.textbox_message_system_log, "Auth Key or language setting is incorrect", "ERROR") chat_message = f"{message}" else: result = self.translator.translate( - translator_name=self.CHOICE_TRANSLATOR, - source_language=self.INPUT_SOURCE_LANG, - target_language=self.INPUT_TARGET_LANG, + translator_name=config.CHOICE_TRANSLATOR, + source_language=config.INPUT_SOURCE_LANG, + target_language=config.INPUT_TARGET_LANG, message=message ) - chat_message = self.MESSAGE_FORMAT.replace("[message]", message).replace("[translation]", result) + chat_message = config.MESSAGE_FORMAT.replace("[message]", message).replace("[translation]", result) # send OSC message if self.ENABLE_OSC is True: - send_message(chat_message, self.OSC_IP_ADDRESS, self.OSC_PORT) + send_message(chat_message, config.OSC_IP_ADDRESS, config.OSC_PORT) else: print_textbox(self.textbox_message_log, "OSC is not enabled, please enable OSC and rejoin.", "ERROR") print_textbox(self.textbox_message_system_log, "OSC is not enabled, please enable OSC and rejoin.", "ERROR") @@ -729,7 +503,7 @@ class App(CTk): print_textbox(self.textbox_message_send_log, f"{chat_message}", "SEND") # delete message in entry message box - if self.ENABLE_AUTO_CLEAR_CHATBOX is True: + if config.ENABLE_AUTO_CLEAR_CHATBOX is True: self.entry_message_box.delete(0, customtkinter.END) BREAK_KEYSYM_LIST = [ @@ -738,7 +512,7 @@ class App(CTk): ] def entry_message_box_press_key_any(self, event): # send OSC typing - send_typing(True, self.OSC_IP_ADDRESS, self.OSC_PORT) + send_typing(True, config.OSC_IP_ADDRESS, config.OSC_PORT) if self.checkbox_foreground.get(): self.attributes("-topmost", False) @@ -749,7 +523,7 @@ class App(CTk): def entry_message_box_leave(self, event): # send OSC typing - send_typing(False, self.OSC_IP_ADDRESS, self.OSC_PORT) + send_typing(False, config.OSC_IP_ADDRESS, config.OSC_PORT) if self.checkbox_foreground.get(): self.attributes("-topmost", True) @@ -776,7 +550,7 @@ class App(CTk): self.tabview_logs.add(main_tab_title_receive) self.tabview_logs.add(main_tab_title_system) self.tabview_logs.grid(row=0, column=1, padx=0, pady=0, sticky="nsew") - self.tabview_logs._segmented_button.configure(font=CTkFont(family=self.FONT_FAMILY)) + self.tabview_logs._segmented_button.configure(font=CTkFont(family=config.FONT_FAMILY)) self.tabview_logs._segmented_button.grid(sticky="W") self.tabview_logs.tab(main_tab_title_log).grid_rowconfigure(0, weight=1) self.tabview_logs.tab(main_tab_title_log).grid_columnconfigure(0, weight=1) @@ -791,7 +565,7 @@ class App(CTk): # add textbox message log self.textbox_message_log = CTkTextbox( self.tabview_logs.tab(main_tab_title_log), - font=CTkFont(family=self.FONT_FAMILY) + font=CTkFont(family=config.FONT_FAMILY) ) self.textbox_message_log.grid(row=0, column=0, padx=0, pady=0, sticky="nsew") self.textbox_message_log.configure(state='disabled') @@ -799,7 +573,7 @@ class App(CTk): # add textbox message send log self.textbox_message_send_log = CTkTextbox( self.tabview_logs.tab(main_tab_title_send), - font=CTkFont(family=self.FONT_FAMILY) + font=CTkFont(family=config.FONT_FAMILY) ) self.textbox_message_send_log.grid(row=0, column=0, padx=0, pady=0, sticky="nsew") self.textbox_message_send_log.configure(state='disabled') @@ -807,7 +581,7 @@ class App(CTk): # add textbox message receive log self.textbox_message_receive_log = CTkTextbox( self.tabview_logs.tab(main_tab_title_receive), - font=CTkFont(family=self.FONT_FAMILY) + font=CTkFont(family=config.FONT_FAMILY) ) self.textbox_message_receive_log.grid(row=0, column=0, padx=0, pady=0, sticky="nsew") self.textbox_message_receive_log.configure(state='disabled') @@ -815,7 +589,7 @@ class App(CTk): # add textbox message system log self.textbox_message_system_log = CTkTextbox( self.tabview_logs.tab(main_tab_title_system), - font=CTkFont(family=self.FONT_FAMILY) + font=CTkFont(family=config.FONT_FAMILY) ) self.textbox_message_system_log.grid(row=0, column=0, padx=0, pady=0, sticky="nsew") self.textbox_message_system_log.configure(state='disabled') diff --git a/config.py b/config.py index fa1a7ce1..8b2d3290 100644 --- a/config.py +++ b/config.py @@ -339,16 +339,6 @@ class Config: self._ENABLE_AUTO_CLEAR_CHATBOX = value save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) - @property - def ENABLE_OSC(self): - return self._ENABLE_OSC - - @ENABLE_OSC.setter - def ENABLE_OSC(self, value): - if type(value) is bool: - self._ENABLE_OSC = value - save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) - @property def ENABLE_NOTICE_XSOVERLAY(self): return self._ENABLE_NOTICE_XSOVERLAY @@ -359,16 +349,6 @@ class Config: self._ENABLE_NOTICE_XSOVERLAY = value save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) - @property - def UPDATE_FLAG(self): - return self._UPDATE_FLAG - - @UPDATE_FLAG.setter - def UPDATE_FLAG(self, value): - if type(value) is bool: - self._UPDATE_FLAG = value - save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) - def init_config(self): self._PATH_CONFIG = "./config.json" self._TRANSPARENCY = 100 @@ -407,9 +387,7 @@ class Config: } self._MESSAGE_FORMAT = "[message]([translation])" self._ENABLE_AUTO_CLEAR_CHATBOX = False - self._ENABLE_OSC = False self._ENABLE_NOTICE_XSOVERLAY = False - self._UPDATE_FLAG = False def load_config(self): if os_path.isfile(self.PATH_CONFIG) is not False: @@ -429,5 +407,4 @@ class Config: config[method] = getattr(self, method) json_dump(config, fp, indent=4) -if __name__ == "__main__": - instance = Config() \ No newline at end of file +config = Config() \ No newline at end of file diff --git a/window_config.py b/window_config.py index 346c4a03..ef18acf2 100644 --- a/window_config.py +++ b/window_config.py @@ -8,7 +8,8 @@ from customtkinter import CTkToplevel, CTkTabview, CTkFont, CTkLabel, CTkSlider, from flashtext import KeywordProcessor from threading import Thread -from utils import save_json, print_textbox, thread_fnc, get_localized_text, get_key_by_value, widget_config_window_label_setter +from config import config +from utils import print_textbox, thread_fnc, get_localized_text, get_key_by_value, widget_config_window_label_setter from audio_utils import get_input_device_list, get_output_device_list, get_default_output_device from audio_recorder import SelectedMicEnergyRecorder, SelectedSpeakeEnergyRecorder from languages import translation_lang, transcription_lang, selectable_languages @@ -42,7 +43,7 @@ class ToplevelWindowConfig(CTkToplevel): self.speaker_energy_plot_progressbar = None # load ui language data - language_yaml_data = get_localized_text(f"{self.parent.UI_LANGUAGE}") + 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 @@ -52,23 +53,20 @@ class ToplevelWindowConfig(CTkToplevel): def slider_transparency_callback(self, value): self.parent.wm_attributes("-alpha", value/100) - self.parent.TRANSPARENCY = value - save_json(self.parent.PATH_CONFIG, "TRANSPARENCY", self.parent.TRANSPARENCY) + config.TRANSPARENCY = value def optionmenu_appearance_theme_callback(self, choice): self.optionmenu_appearance_theme.set(choice) customtkinter.set_appearance_mode(choice) - self.parent.APPEARANCE_THEME = choice - save_json(self.parent.PATH_CONFIG, "APPEARANCE_THEME", self.parent.APPEARANCE_THEME) + 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) - self.parent.UI_SCALING = choice - save_json(self.parent.PATH_CONFIG, "UI_SCALING", self.parent.UI_SCALING) + config.UI_SCALING = choice def optionmenu_font_family_callback(self, choice): self.optionmenu_font_family.set(choice) @@ -176,18 +174,15 @@ class ToplevelWindowConfig(CTkToplevel): except: pass - self.parent.FONT_FAMILY = choice - save_json(self.parent.PATH_CONFIG, "FONT_FAMILY", self.parent.FONT_FAMILY) + 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"{self.parent.UI_LANGUAGE}") - self.parent.UI_LANGUAGE = get_key_by_value(selectable_languages, choice) - language_yaml_data = get_localized_text(f"{self.parent.UI_LANGUAGE}") - save_json(self.parent.PATH_CONFIG, "UI_LANGUAGE", self.parent.UI_LANGUAGE) - + 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) @@ -207,7 +202,7 @@ class ToplevelWindowConfig(CTkToplevel): def optionmenu_translation_translator_callback(self, choice): self.optionmenu_translation_translator.set(choice) - if self.parent.translator.authentication(choice, self.parent.AUTH_KEYS[choice]) is False: + if self.parent.translator.authentication(choice, config.AUTH_KEYS[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: @@ -234,44 +229,30 @@ class ToplevelWindowConfig(CTkToplevel): self.scrollableDropdown_translation_output_target_language.configure( values=list(translation_lang[choice]["target"].keys())) - self.parent.CHOICE_TRANSLATOR = choice - self.parent.INPUT_SOURCE_LANG = list(translation_lang[choice]["source"].keys())[0] - self.parent.INPUT_TARGET_LANG = list(translation_lang[choice]["target"].keys())[1] - self.parent.OUTPUT_SOURCE_LANG = list(translation_lang[choice]["source"].keys())[1] - self.parent.OUTPUT_TARGET_LANG = list(translation_lang[choice]["target"].keys())[0] - save_json(self.parent.PATH_CONFIG, "CHOICE_TRANSLATOR", self.parent.CHOICE_TRANSLATOR) - save_json(self.parent.PATH_CONFIG, "INPUT_SOURCE_LANG", self.parent.INPUT_SOURCE_LANG) - save_json(self.parent.PATH_CONFIG, "INPUT_TARGET_LANG", self.parent.INPUT_TARGET_LANG) - save_json(self.parent.PATH_CONFIG, "OUTPUT_SOURCE_LANG", self.parent.OUTPUT_SOURCE_LANG) - save_json(self.parent.PATH_CONFIG, "OUTPUT_TARGET_LANG", self.parent.OUTPUT_TARGET_LANG) + 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) - - self.parent.INPUT_SOURCE_LANG = choice - save_json(self.parent.PATH_CONFIG, "INPUT_SOURCE_LANG", self.parent.INPUT_SOURCE_LANG) + config.INPUT_SOURCE_LANG = choice def optionmenu_translation_input_target_language_callback(self, choice): self.optionmenu_translation_input_target_language.set(choice) - - self.parent.INPUT_TARGET_LANG = choice - save_json(self.parent.PATH_CONFIG, "INPUT_TARGET_LANG", self.parent.INPUT_TARGET_LANG) + config.INPUT_TARGET_LANG = choice def optionmenu_translation_output_source_language_callback(self, choice): self.optionmenu_translation_output_source_language.set(choice) - - self.parent.OUTPUT_SOURCE_LANG = choice - save_json(self.parent.PATH_CONFIG, "OUTPUT_SOURCE_LANG", self.parent.OUTPUT_SOURCE_LANG) + config.OUTPUT_SOURCE_LANG = choice def optionmenu_translation_output_target_language_callback(self, choice): self.optionmenu_translation_output_target_language.set(choice) - - self.parent.OUTPUT_TARGET_LANG = choice - save_json(self.parent.PATH_CONFIG, "OUTPUT_TARGET_LANG", self.parent.OUTPUT_TARGET_LANG) + config.OUTPUT_TARGET_LANG = choice def optionmenu_input_mic_host_callback(self, choice): self.optionmenu_input_mic_host.set(choice) - self.optionmenu_input_mic_device.configure( values=[device["name"] for device in get_input_device_list()[choice]], variable=StringVar(value=[device["name"] for device in get_input_device_list()[choice]][0])) @@ -279,24 +260,18 @@ class ToplevelWindowConfig(CTkToplevel): if SCROLLABLE_DROPDOWN: self.scrollableDropdown_input_mic_device.configure(values=[device["name"] for device in get_input_device_list()[choice]]) - self.parent.CHOICE_MIC_HOST = choice - self.parent.CHOICE_MIC_DEVICE = [device["name"] for device in get_input_device_list()[choice]][0] - save_json(self.parent.PATH_CONFIG, "CHOICE_MIC_HOST", self.parent.CHOICE_MIC_HOST) - save_json(self.parent.PATH_CONFIG, "CHOICE_MIC_DEVICE", self.parent.CHOICE_MIC_DEVICE) + config.CHOICE_MIC_HOST = choice + config.CHOICE_MIC_DEVICE = [device["name"] for device in get_input_device_list()[choice]][0] def optionmenu_input_mic_device_callback(self, choice): self.optionmenu_input_mic_device.set(choice) - - self.parent.CHOICE_MIC_DEVICE = choice - save_json(self.parent.PATH_CONFIG, "CHOICE_MIC_DEVICE", self.parent.CHOICE_MIC_DEVICE) + 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) - - self.parent.INPUT_MIC_VOICE_LANGUAGE = choice - save_json(self.parent.PATH_CONFIG, "INPUT_MIC_VOICE_LANGUAGE", self.parent.INPUT_MIC_VOICE_LANGUAGE) + config.INPUT_MIC_VOICE_LANGUAGE = choice def progressBar_input_mic_energy_plot(self): if self.mic_energy_queue.empty() is False: @@ -309,7 +284,7 @@ class ToplevelWindowConfig(CTkToplevel): def mic_threshold_check_start(self): self.mic_energy_queue = Queue() - mic_device = [device for device in get_input_device_list()[self.parent.CHOICE_MIC_HOST] if device["name"] == self.parent.CHOICE_MIC_DEVICE][0] + mic_device = [device for device in get_input_device_list()[config.CHOICE_MIC_HOST] if device["name"] == config.CHOICE_MIC_DEVICE][0] self.mic_energy_recorder = SelectedMicEnergyRecorder(mic_device) self.mic_energy_recorder.record_into_queue(self.mic_energy_queue) self.mic_energy_plot_progressbar = thread_fnc(self.progressBar_input_mic_energy_plot) @@ -341,55 +316,45 @@ class ToplevelWindowConfig(CTkToplevel): th_mic_threshold_check_stop.start() def slider_input_mic_energy_threshold_callback(self, value): - self.parent.INPUT_MIC_ENERGY_THRESHOLD = int(value) - save_json(self.parent.PATH_CONFIG, "INPUT_MIC_ENERGY_THRESHOLD", self.parent.INPUT_MIC_ENERGY_THRESHOLD) + config.INPUT_MIC_ENERGY_THRESHOLD = int(value) def checkbox_input_mic_dynamic_energy_threshold_callback(self): - value = self.checkbox_input_mic_dynamic_energy_threshold.get() - self.parent.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD = value - save_json(self.parent.PATH_CONFIG, "INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD", self.parent.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD) + config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD = self.checkbox_input_mic_dynamic_energy_threshold.get() def entry_input_mic_record_timeout_callback(self, event): - self.parent.INPUT_MIC_RECORD_TIMEOUT = int(self.entry_input_mic_record_timeout.get()) - save_json(self.parent.PATH_CONFIG, "INPUT_MIC_RECORD_TIMEOUT", self.parent.INPUT_MIC_RECORD_TIMEOUT) + config.INPUT_MIC_RECORD_TIMEOUT = int(self.entry_input_mic_record_timeout.get()) def entry_input_mic_phrase_timeout_callback(self, event): - self.parent.INPUT_MIC_PHRASE_TIMEOUT = int(self.entry_input_mic_phrase_timeout.get()) - save_json(self.parent.PATH_CONFIG, "INPUT_MIC_PHRASE_TIMEOUT", self.parent.INPUT_MIC_PHRASE_TIMEOUT) + config.INPUT_MIC_PHRASE_TIMEOUT = int(self.entry_input_mic_phrase_timeout.get()) def entry_input_mic_max_phrases_callback(self, event): - self.parent.INPUT_MIC_MAX_PHRASES = int(self.entry_input_mic_max_phrases.get()) - save_json(self.parent.PATH_CONFIG, "INPUT_MIC_MAX_PHRASES", self.parent.INPUT_MIC_MAX_PHRASES) + 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: - self.parent.INPUT_MIC_WORD_FILTER = word_filter.split(",") + config.INPUT_MIC_WORD_FILTER = word_filter.split(",") else: - self.parent.INPUT_MIC_WORD_FILTER = [] + config.INPUT_MIC_WORD_FILTER = [] self.parent.keyword_processor = KeywordProcessor() for f in self.parent.INPUT_MIC_WORD_FILTER: self.parent.keyword_processor.add_keyword(f) - save_json(self.parent.PATH_CONFIG, "INPUT_MIC_WORD_FILTER", self.parent.INPUT_MIC_WORD_FILTER) def optionmenu_input_speaker_device_callback(self, choice): speaker_device = [device for device in get_output_device_list() if device["name"] == choice][0] if get_default_output_device()["index"] == speaker_device["index"]: self.optionmenu_input_speaker_device.set(choice) - self.parent.CHOICE_SPEAKER_DEVICE = choice - save_json(self.parent.PATH_CONFIG, "CHOICE_SPEAKER_DEVICE", self.parent.CHOICE_SPEAKER_DEVICE) + 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=self.parent.CHOICE_SPEAKER_DEVICE)) + 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) - - self.parent.INPUT_SPEAKER_VOICE_LANGUAGE = choice - save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_VOICE_LANGUAGE", self.parent.INPUT_SPEAKER_VOICE_LANGUAGE) + config.INPUT_SPEAKER_VOICE_LANGUAGE = choice def progressBar_input_speaker_energy_plot(self): if self.speaker_energy_queue.empty() is False: @@ -406,7 +371,7 @@ class ToplevelWindowConfig(CTkToplevel): self.speaker_energy_queue.put(energy) def speaker_threshold_check_start(self): - speaker_device = [device for device in get_output_device_list() if device["name"] == self.parent.CHOICE_SPEAKER_DEVICE][0] + speaker_device = [device for device in get_output_device_list() if device["name"] == config.CHOICE_SPEAKER_DEVICE][0] if get_default_output_device()["index"] == speaker_device["index"]: self.speaker_energy_queue = Queue() @@ -448,54 +413,41 @@ class ToplevelWindowConfig(CTkToplevel): th_speaker_threshold_check_stop.start() def slider_input_speaker_energy_threshold_callback(self, value): - self.parent.INPUT_SPEAKER_ENERGY_THRESHOLD = int(value) - save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_ENERGY_THRESHOLD", self.parent.INPUT_SPEAKER_ENERGY_THRESHOLD) + config.INPUT_SPEAKER_ENERGY_THRESHOLD = int(value) def checkbox_input_speaker_dynamic_energy_threshold_callback(self): - value = self.checkbox_input_speaker_dynamic_energy_threshold.get() - self.parent.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = value - save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD", self.parent.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD) + config.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = self.checkbox_input_speaker_dynamic_energy_threshold.get() def entry_input_speaker_record_timeout_callback(self, event): - self.parent.INPUT_SPEAKER_RECORD_TIMEOUT = int(self.entry_input_speaker_record_timeout.get()) - save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_RECORD_TIMEOUT", self.parent.INPUT_SPEAKER_RECORD_TIMEOUT) + config.INPUT_SPEAKER_RECORD_TIMEOUT = int(self.entry_input_speaker_record_timeout.get()) def entry_input_speaker_phrase_timeout_callback(self, event): - self.parent.INPUT_SPEAKER_PHRASE_TIMEOUT = int(self.entry_input_speaker_phrase_timeout.get()) - save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_PHRASE_TIMEOUT", self.parent.INPUT_SPEAKER_PHRASE_TIMEOUT) + config.INPUT_SPEAKER_PHRASE_TIMEOUT = int(self.entry_input_speaker_phrase_timeout.get()) def entry_input_speaker_max_phrases_callback(self, event): - self.parent.INPUT_SPEAKER_MAX_PHRASES = int(self.entry_input_speaker_max_phrases.get()) - save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_MAX_PHRASES", self.parent.INPUT_SPEAKER_MAX_PHRASES) + config.INPUT_SPEAKER_MAX_PHRASES = int(self.entry_input_speaker_max_phrases.get()) def entry_ip_address_callback(self, event): - self.parent.OSC_IP_ADDRESS = self.entry_ip_address.get() - save_json(self.parent.PATH_CONFIG, "OSC_IP_ADDRESS", self.parent.OSC_IP_ADDRESS) + config.OSC_IP_ADDRESS = self.entry_ip_address.get() def entry_port_callback(self, event): - self.parent.OSC_PORT = self.entry_port.get() - save_json(self.parent.PATH_CONFIG, "OSC_PORT", self.parent.OSC_PORT) + config.OSC_PORT = self.entry_port.get() def entry_authkey_callback(self, event): value = self.entry_authkey.get() if len(value) > 0: if self.parent.translator.authentication("DeepL(auth)", value) is True: - self.parent.AUTH_KEYS["DeepL(auth)"] = value - save_json(self.parent.PATH_CONFIG, "AUTH_KEYS", self.parent.AUTH_KEYS) + config.AUTH_KEYS["DeepL(auth)"] = value 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): - value = self.checkbox_auto_clear_chatbox.get() - self.parent.ENABLE_AUTO_CLEAR_CHATBOX = value - save_json(self.parent.PATH_CONFIG, "ENABLE_AUTO_CLEAR_CHATBOX", self.parent.ENABLE_AUTO_CLEAR_CHATBOX) + config.ENABLE_AUTO_CLEAR_CHATBOX = self.checkbox_auto_clear_chatbox.get() def checkbox_notice_xsoverlay_callback(self): - value = self.checkbox_notice_xsoverlay.get() - self.parent.ENABLE_NOTICE_XSOVERLAY = value - save_json(self.parent.PATH_CONFIG, "ENABLE_NOTICE_XSOVERLAY", self.parent.ENABLE_NOTICE_XSOVERLAY) + config.ENABLE_NOTICE_XSOVERLAY = self.checkbox_notice_xsoverlay.get() def delete_window(self): self.checkbox_input_mic_threshold_check.deselect() @@ -522,8 +474,7 @@ class ToplevelWindowConfig(CTkToplevel): def entry_message_format_callback(self, event): value = self.entry_message_format.get() if len(value) > 0: - self.parent.MESSAGE_FORMAT = value - save_json(self.parent.PATH_CONFIG, "MESSAGE_FORMAT", self.parent.MESSAGE_FORMAT) + 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"]) @@ -554,7 +505,7 @@ class ToplevelWindowConfig(CTkToplevel): 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=self.parent.FONT_FAMILY)) + self.tabview_config._segmented_button.configure(font=CTkFont(family=config.FONT_FAMILY)) self.tabview_config._segmented_button.grid(sticky="W") # tab UI @@ -566,7 +517,7 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_ui), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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( @@ -574,7 +525,7 @@ class ToplevelWindowConfig(CTkToplevel): from_=50, to=100, command=self.slider_transparency_callback, - variable=DoubleVar(value=self.parent.TRANSPARENCY), + variable=DoubleVar(value=config.TRANSPARENCY), ) self.slider_transparency.grid(row=row, column=1, columnspan=1, padx=padx, pady=10, sticky="nsew") @@ -584,16 +535,16 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_ui), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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=self.parent.APPEARANCE_THEME), - font=CTkFont(family=self.parent.FONT_FAMILY), - dropdown_font=CTkFont(family=self.parent.FONT_FAMILY), + 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") @@ -605,7 +556,7 @@ class ToplevelWindowConfig(CTkToplevel): justify="left", button_color="transparent", command=self.optionmenu_appearance_theme_callback, - font=CTkFont(family=self.parent.FONT_FAMILY), + font=CTkFont(family=config.FONT_FAMILY), ) self.scrollableDropdown_appearance_theme.bind( "", @@ -618,16 +569,16 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_ui), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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=self.parent.UI_SCALING), - font=CTkFont(family=self.parent.FONT_FAMILY), - dropdown_font=CTkFont(family=self.parent.FONT_FAMILY), + 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") @@ -639,7 +590,7 @@ class ToplevelWindowConfig(CTkToplevel): justify="left", button_color="transparent", command=self.optionmenu_ui_scaling_callback, - font=CTkFont(family=self.parent.FONT_FAMILY), + font=CTkFont(family=config.FONT_FAMILY), ) self.scrollableDropdown_ui_scaling.bind( "", @@ -652,7 +603,7 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_ui), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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()) @@ -660,9 +611,9 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_ui), values=font_families, command=self.optionmenu_font_family_callback, - variable=StringVar(value=self.parent.FONT_FAMILY), - font=CTkFont(family=self.parent.FONT_FAMILY), - dropdown_font=CTkFont(family=self.parent.FONT_FAMILY), + 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") @@ -674,7 +625,7 @@ class ToplevelWindowConfig(CTkToplevel): justify="left", button_color="transparent", command=self.optionmenu_font_family_callback, - font=CTkFont(family=self.parent.FONT_FAMILY), + font=CTkFont(family=config.FONT_FAMILY), ) self.scrollableDropdown_font_family.bind( "", @@ -687,7 +638,7 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_ui), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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()) @@ -695,9 +646,9 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_ui), values=selectable_languages_values, command=self.optionmenu_ui_language_callback, - variable=StringVar(value=selectable_languages[self.parent.UI_LANGUAGE]), - font=CTkFont(family=self.parent.FONT_FAMILY), - dropdown_font=CTkFont(family=self.parent.FONT_FAMILY), + 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") @@ -709,7 +660,7 @@ class ToplevelWindowConfig(CTkToplevel): justify="left", button_color="transparent", command=self.optionmenu_ui_language_callback, - font=CTkFont(family=self.parent.FONT_FAMILY), + font=CTkFont(family=config.FONT_FAMILY), ) self.scrollableDropdown_ui_language.bind( "", @@ -725,16 +676,16 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_translation), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY), + 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=list(self.parent.translator.translator_status.keys()), command=self.optionmenu_translation_translator_callback, - variable=StringVar(value=self.parent.CHOICE_TRANSLATOR), - font=CTkFont(family=self.parent.FONT_FAMILY), - dropdown_font=CTkFont(family=self.parent.FONT_FAMILY), + 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") @@ -746,7 +697,7 @@ class ToplevelWindowConfig(CTkToplevel): justify="left", button_color="transparent", command=self.optionmenu_translation_translator_callback, - font=CTkFont(family=self.parent.FONT_FAMILY), + font=CTkFont(family=config.FONT_FAMILY), ) self.scrollableDropdown_translation_translator.bind( "", @@ -759,7 +710,7 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_translation), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + font=CTkFont(family=config.FONT_FAMILY) ) self.label_translation_input_language.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") @@ -767,10 +718,10 @@ class ToplevelWindowConfig(CTkToplevel): 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[self.parent.CHOICE_TRANSLATOR]["source"].keys()), - variable=StringVar(value=self.parent.INPUT_SOURCE_LANG), - font=CTkFont(family=self.parent.FONT_FAMILY), - dropdown_font=CTkFont(family=self.parent.FONT_FAMILY), + 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") @@ -778,11 +729,11 @@ class ToplevelWindowConfig(CTkToplevel): if SCROLLABLE_DROPDOWN: self.scrollableDropdown_translation_input_source_language = CTkScrollableDropdown( self.optionmenu_translation_input_source_language, - values=list(translation_lang[self.parent.CHOICE_TRANSLATOR]["source"].keys()), + 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=self.parent.FONT_FAMILY), + font=CTkFont(family=config.FONT_FAMILY), ) self.scrollableDropdown_translation_input_source_language.bind( "", @@ -794,7 +745,7 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_translation), text="-->", fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + font=CTkFont(family=config.FONT_FAMILY) ) self.label_translation_input_arrow.grid(row=row, column=2, columnspan=1, padx=padx, pady=pady, sticky="nsew") @@ -802,10 +753,10 @@ class ToplevelWindowConfig(CTkToplevel): 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[self.parent.CHOICE_TRANSLATOR]["target"].keys()), - variable=StringVar(value=self.parent.INPUT_TARGET_LANG), - font=CTkFont(family=self.parent.FONT_FAMILY), - dropdown_font=CTkFont(family=self.parent.FONT_FAMILY), + 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") @@ -813,11 +764,11 @@ class ToplevelWindowConfig(CTkToplevel): if SCROLLABLE_DROPDOWN: self.scrollableDropdown_translation_input_target_language = CTkScrollableDropdown( self.optionmenu_translation_input_target_language, - values=list(translation_lang[self.parent.CHOICE_TRANSLATOR]["target"].keys()), + 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=self.parent.FONT_FAMILY), + font=CTkFont(family=config.FONT_FAMILY), ) self.scrollableDropdown_translation_input_target_language.bind( "", @@ -830,7 +781,7 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_translation), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + font=CTkFont(family=config.FONT_FAMILY) ) self.label_translation_output_language.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") @@ -838,10 +789,10 @@ class ToplevelWindowConfig(CTkToplevel): 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[self.parent.CHOICE_TRANSLATOR]["source"].keys()), - variable=StringVar(value=self.parent.OUTPUT_SOURCE_LANG), - font=CTkFont(family=self.parent.FONT_FAMILY), - dropdown_font=CTkFont(family=self.parent.FONT_FAMILY), + 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") @@ -849,11 +800,11 @@ class ToplevelWindowConfig(CTkToplevel): if SCROLLABLE_DROPDOWN: self.scrollableDropdown_translation_output_source_language = CTkScrollableDropdown( self.optionmenu_translation_output_source_language, - values=list(translation_lang[self.parent.CHOICE_TRANSLATOR]["source"].keys()), + 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=self.parent.FONT_FAMILY), + font=CTkFont(family=config.FONT_FAMILY), ) self.scrollableDropdown_translation_output_source_language.bind( "", @@ -865,7 +816,7 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_translation), text="-->", fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + font=CTkFont(family=config.FONT_FAMILY) ) self.label_translation_output_arrow.grid(row=row, column=2, columnspan=1, padx=padx, pady=pady, sticky="nsew") @@ -873,10 +824,10 @@ class ToplevelWindowConfig(CTkToplevel): 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[self.parent.CHOICE_TRANSLATOR]["target"].keys()), - variable=StringVar(value=self.parent.OUTPUT_TARGET_LANG), - font=CTkFont(family=self.parent.FONT_FAMILY), - dropdown_font=CTkFont(family=self.parent.FONT_FAMILY), + 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") @@ -884,11 +835,11 @@ class ToplevelWindowConfig(CTkToplevel): if SCROLLABLE_DROPDOWN: self.scrollableDropdown_translation_output_target_language = CTkScrollableDropdown( self.optionmenu_translation_output_target_language, - values=list(translation_lang[self.parent.CHOICE_TRANSLATOR]["target"].keys()), + 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=self.parent.FONT_FAMILY), + font=CTkFont(family=config.FONT_FAMILY), ) self.scrollableDropdown_translation_output_target_language.bind( "", @@ -904,16 +855,16 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_transcription), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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=[host for host in get_input_device_list().keys()], command=self.optionmenu_input_mic_host_callback, - variable=StringVar(value=self.parent.CHOICE_MIC_HOST), - font=CTkFont(family=self.parent.FONT_FAMILY), - dropdown_font=CTkFont(family=self.parent.FONT_FAMILY), + 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") @@ -925,7 +876,7 @@ class ToplevelWindowConfig(CTkToplevel): justify="left", button_color="transparent", command=self.optionmenu_input_mic_host_callback, - font=CTkFont(family=self.parent.FONT_FAMILY), + font=CTkFont(family=config.FONT_FAMILY), ) self.scrollableDropdown_input_mic_host.bind( "", @@ -938,16 +889,16 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_transcription), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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=[device["name"] for device in get_input_device_list()[self.parent.CHOICE_MIC_HOST]], + values=[device["name"] for device in get_input_device_list()[config.CHOICE_MIC_HOST]], command=self.optionmenu_input_mic_device_callback, - variable=StringVar(value=self.parent.CHOICE_MIC_DEVICE), - font=CTkFont(family=self.parent.FONT_FAMILY), - dropdown_font=CTkFont(family=self.parent.FONT_FAMILY), + 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") @@ -955,11 +906,11 @@ class ToplevelWindowConfig(CTkToplevel): if SCROLLABLE_DROPDOWN: self.scrollableDropdown_input_mic_device = CTkScrollableDropdown( self.optionmenu_input_mic_device, - values=[device["name"] for device in get_input_device_list()[self.parent.CHOICE_MIC_HOST]], + values=[device["name"] for device in get_input_device_list()[config.CHOICE_MIC_HOST]], justify="left", button_color="transparent", command=self.optionmenu_input_mic_device_callback, - font=CTkFont(family=self.parent.FONT_FAMILY), + font=CTkFont(family=config.FONT_FAMILY), ) self.scrollableDropdown_input_mic_device.bind( "", @@ -972,16 +923,16 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_transcription), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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=self.parent.INPUT_MIC_VOICE_LANGUAGE), - font=CTkFont(family=self.parent.FONT_FAMILY), - dropdown_font=CTkFont(family=self.parent.FONT_FAMILY), + 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") @@ -993,7 +944,7 @@ class ToplevelWindowConfig(CTkToplevel): justify="left", button_color="transparent", command=self.optionmenu_input_mic_voice_language_callback, - font=CTkFont(family=self.parent.FONT_FAMILY), + font=CTkFont(family=config.FONT_FAMILY), ) self.scrollableDropdown_input_voice_language.bind( "", @@ -1006,7 +957,7 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_transcription), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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") @@ -1019,7 +970,7 @@ class ToplevelWindowConfig(CTkToplevel): button_corner_radius=3, number_of_steps=self.MAX_MIC_ENERGY_THRESHOLD, command=self.slider_input_mic_energy_threshold_callback, - variable=IntVar(value=self.parent.INPUT_MIC_ENERGY_THRESHOLD), + 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") @@ -1031,7 +982,7 @@ class ToplevelWindowConfig(CTkToplevel): onvalue=True, offvalue=False, command=self.checkbox_input_mic_threshold_check_callback, - font=CTkFont(family=self.parent.FONT_FAMILY) + 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") @@ -1048,7 +999,7 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_transcription), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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( @@ -1057,10 +1008,10 @@ class ToplevelWindowConfig(CTkToplevel): onvalue=True, offvalue=False, command=self.checkbox_input_mic_dynamic_energy_threshold_callback, - font=CTkFont(family=self.parent.FONT_FAMILY) + 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 self.parent.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD is True: + 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() @@ -1071,13 +1022,13 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_transcription), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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=self.parent.INPUT_MIC_RECORD_TIMEOUT), - font=CTkFont(family=self.parent.FONT_FAMILY) + 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) @@ -1088,13 +1039,13 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_transcription), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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=self.parent.INPUT_MIC_PHRASE_TIMEOUT), - font=CTkFont(family=self.parent.FONT_FAMILY) + 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) @@ -1105,13 +1056,13 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_transcription), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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=self.parent.INPUT_MIC_MAX_PHRASES), - font=CTkFont(family=self.parent.FONT_FAMILY) + 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) @@ -1122,18 +1073,18 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_transcription), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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(self.parent.INPUT_MIC_WORD_FILTER) > 0: - textvariable=StringVar(value=",".join(self.parent.INPUT_MIC_WORD_FILTER)) + 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=self.parent.FONT_FAMILY) + 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) @@ -1144,16 +1095,16 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_transcription), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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=[device["name"] for device in get_output_device_list()], command=self.optionmenu_input_speaker_device_callback, - variable=StringVar(value=self.parent.CHOICE_SPEAKER_DEVICE), - font=CTkFont(family=self.parent.FONT_FAMILY), - dropdown_font=CTkFont(family=self.parent.FONT_FAMILY), + 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") @@ -1165,7 +1116,7 @@ class ToplevelWindowConfig(CTkToplevel): justify="left", button_color="transparent", command=self.optionmenu_input_speaker_device_callback, - font=CTkFont(family=self.parent.FONT_FAMILY), + font=CTkFont(family=config.FONT_FAMILY), ) self.scrollableDropdown_input_speaker_device.bind( "", @@ -1178,16 +1129,16 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_transcription), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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=self.parent.INPUT_SPEAKER_VOICE_LANGUAGE), - font=CTkFont(family=self.parent.FONT_FAMILY), - dropdown_font=CTkFont(family=self.parent.FONT_FAMILY), + 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") @@ -1199,7 +1150,7 @@ class ToplevelWindowConfig(CTkToplevel): justify="left", button_color="transparent", command=self.optionmenu_input_speaker_voice_language_callback, - font=CTkFont(family=self.parent.FONT_FAMILY), + font=CTkFont(family=config.FONT_FAMILY), ) self.scrollableDropdown_input_speaker_voice_language.bind( "", @@ -1212,7 +1163,7 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_transcription), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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") @@ -1226,7 +1177,7 @@ class ToplevelWindowConfig(CTkToplevel): button_corner_radius=3, number_of_steps=self.MAX_SPEAKER_ENERGY_THRESHOLD, command=self.slider_input_speaker_energy_threshold_callback, - variable=IntVar(value=self.parent.INPUT_SPEAKER_ENERGY_THRESHOLD), + 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") @@ -1238,7 +1189,7 @@ class ToplevelWindowConfig(CTkToplevel): onvalue=True, offvalue=False, command=self.checkbox_input_speaker_threshold_check_callback, - font=CTkFont(family=self.parent.FONT_FAMILY) + 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") @@ -1255,7 +1206,7 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_transcription), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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( @@ -1264,10 +1215,10 @@ class ToplevelWindowConfig(CTkToplevel): onvalue=True, offvalue=False, command=self.checkbox_input_speaker_dynamic_energy_threshold_callback, - font=CTkFont(family=self.parent.FONT_FAMILY) + 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 self.parent.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD is True: + 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() @@ -1278,13 +1229,13 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_transcription), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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=self.parent.INPUT_SPEAKER_RECORD_TIMEOUT), - font=CTkFont(family=self.parent.FONT_FAMILY) + 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) @@ -1295,13 +1246,13 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_transcription), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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=self.parent.INPUT_SPEAKER_PHRASE_TIMEOUT), - font=CTkFont(family=self.parent.FONT_FAMILY) + 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) @@ -1312,13 +1263,13 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_transcription), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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=self.parent.INPUT_SPEAKER_MAX_PHRASES), - font=CTkFont(family=self.parent.FONT_FAMILY) + 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) @@ -1332,13 +1283,13 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_parameter), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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=self.parent.OSC_IP_ADDRESS), - font=CTkFont(family=self.parent.FONT_FAMILY) + 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) @@ -1349,13 +1300,13 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_parameter), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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=self.parent.OSC_PORT), - font=CTkFont(family=self.parent.FONT_FAMILY) + 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) @@ -1366,13 +1317,13 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_parameter), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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=self.parent.AUTH_KEYS["DeepL(auth)"]), - font=CTkFont(family=self.parent.FONT_FAMILY) + 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) @@ -1383,13 +1334,13 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_parameter), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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=self.parent.MESSAGE_FORMAT), - font=CTkFont(family=self.parent.FONT_FAMILY) + 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) @@ -1401,7 +1352,7 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_others), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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( @@ -1410,10 +1361,10 @@ class ToplevelWindowConfig(CTkToplevel): onvalue=True, offvalue=False, command=self.checkbox_auto_clear_chatbox_callback, - font=CTkFont(family=self.parent.FONT_FAMILY) + 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 self.parent.ENABLE_AUTO_CLEAR_CHATBOX is True: + if config.ENABLE_AUTO_CLEAR_CHATBOX is True: self.checkbox_auto_clear_chatbox.select() else: self.checkbox_auto_clear_chatbox.deselect() @@ -1424,7 +1375,7 @@ class ToplevelWindowConfig(CTkToplevel): self.tabview_config.tab(config_tab_title_others), text=init_lang_text, fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) + 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( @@ -1433,10 +1384,10 @@ class ToplevelWindowConfig(CTkToplevel): onvalue=True, offvalue=False, command=self.checkbox_notice_xsoverlay_callback, - font=CTkFont(family=self.parent.FONT_FAMILY) + font=CTkFont(family=config.FONT_FAMILY) ) self.checkbox_notice_xsoverlay.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - if self.parent.ENABLE_NOTICE_XSOVERLAY is True: + if config.ENABLE_NOTICE_XSOVERLAY is True: self.checkbox_notice_xsoverlay.select() else: self.checkbox_notice_xsoverlay.deselect() diff --git a/window_information.py b/window_information.py index 8e912c0d..cc8d8792 100644 --- a/window_information.py +++ b/window_information.py @@ -1,5 +1,6 @@ import os from customtkinter import CTkToplevel, CTkTextbox, CTkFont +from config import config class ToplevelWindowInformation(CTkToplevel): def __init__(self, parent, *args, **kwargs): @@ -16,7 +17,7 @@ class ToplevelWindowInformation(CTkToplevel): # create textbox information self.textbox_information = CTkTextbox( self, - font=CTkFont(family=self.parent.FONT_FAMILY) + 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)