Config Windowの各項目Callback関数をmain.pyコントローラで実行できるように

This commit is contained in:
Sakamoto Shiina
2023-09-01 02:25:00 +09:00
parent ed88a5b886
commit 799a1a27bb
10 changed files with 282 additions and 61 deletions

View File

@@ -2,6 +2,7 @@ from time import sleep
from customtkinter import StringVar, IntVar
from utils import callFunctionIfCallable
from .._SettingBoxGenerator import _SettingBoxGenerator
@@ -13,10 +14,10 @@ def createSettingBox_AdvancedSettings(setting_box_wrapper, config_window, settin
def entry_ip_address_callback(value):
config.OSC_IP_ADDRESS = str(value)
callFunctionIfCallable(config_window.CALLBACK_SET_OSC_IP_ADDRESS, value)
def entry_port_callback(value):
config.OSC_PORT = int(value)
callFunctionIfCallable(config_window.CALLBACK_SET_OSC_PORT, value)
row=0
config_window.sb__ip_address = createSettingBoxEntry(

View File

@@ -3,7 +3,7 @@ from time import sleep
from customtkinter import StringVar, IntVar
from tkinter import font as tk_font
from languages import selectable_languages
from utils import get_key_by_value
from utils import get_key_by_value, callFunctionIfCallable
from .._SettingBoxGenerator import _SettingBoxGenerator
@@ -15,28 +15,25 @@ def createSettingBox_Appearance(setting_box_wrapper, config_window, settings):
createSettingBoxDropdownMenu = sbg.createSettingBoxDropdownMenu
createSettingBoxSlider = sbg.createSettingBoxSlider
# 関数名は変えるかもしれない。
# テーマ変更、フォント変更時、 Widget再生成か再起動かは検討中
# テーマ変更、フォント変更時、 Widget再生成か再起動かは検討中\
def slider_transparency_callback(value):
# self.parent.wm_attributes("-alpha", int(value/100))
config.TRANSPARENCY = int(value)
callFunctionIfCallable(config_window.CALLBACK_SET_TRANSPARENCY, value)
def optionmenu_appearance_theme_callback(value):
config.APPEARANCE_THEME = value
callFunctionIfCallable(config_window.CALLBACK_SET_APPEARANCE, value)
def optionmenu_ui_scaling_callback(value):
callFunctionIfCallable(config_window.CALLBACK_SET_UI_SCALING, value)
# self.optionmenu_ui_scaling.set(choice)
# new_scaling_float = int(choice.replace("%", "")) / 100
config.UI_SCALING = value
def optionmenu_font_family_callback(value):
config.FONT_FAMILY = value
callFunctionIfCallable(config_window.CALLBACK_SET_FONT_FAMILY, value)
def optionmenu_ui_language_callback(value):
config.UI_LANGUAGE = get_key_by_value(selectable_languages, value)
value = get_key_by_value(selectable_languages, value)
callFunctionIfCallable(config_window.CALLBACK_SET_UI_LANGUAGE, value)
row=0
config_window.sb__transparency = createSettingBoxSlider(

View File

@@ -2,6 +2,7 @@ from time import sleep
from customtkinter import StringVar, IntVar
from utils import callFunctionIfCallable
from .._SettingBoxGenerator import _SettingBoxGenerator
@@ -15,16 +16,13 @@ def createSettingBox_Others(setting_box_wrapper, config_window, settings):
# 関数名 chatbox から messagebox に変える予定 config.ENABLE_AUTO_CLEAR_CHATBOX も MESSAGEBOXに変えるかな。
def checkbox_auto_clear_chatbox_callback(checkbox_box_widget):
print(checkbox_box_widget.get())
config.ENABLE_AUTO_CLEAR_CHATBOX = checkbox_box_widget.get()
callFunctionIfCallable(config_window.CALLBACK_SET_DEEPL_AUTHKEY, checkbox_box_widget.get())
def checkbox_notice_xsoverlay_callback(checkbox_box_widget):
print(checkbox_box_widget.get())
config.ENABLE_NOTICE_XSOVERLAY = checkbox_box_widget.get()
callFunctionIfCallable(config_window.CALLBACK_SET_ENABLE_NOTICE_XSOVERLAY, checkbox_box_widget.get())
def entry_message_format_callback(value):
if len(value) > 0:
config.MESSAGE_FORMAT = value
callFunctionIfCallable(config_window.CALLBACK_SET_ENABLE_NOTICE_XSOVERLAY, value)
row=0

View File

@@ -2,6 +2,7 @@ from time import sleep
from customtkinter import StringVar, IntVar
from utils import callFunctionIfCallable
from .._SettingBoxGenerator import _SettingBoxGenerator
@@ -39,42 +40,29 @@ def createSettingBox_Mic(setting_box_wrapper, config_window, settings):
passive_button_wrapper_widget.grid()
def optionmenu_mic_host_callback(value):
config.CHOICE_MIC_HOST = value
callFunctionIfCallable(config_window.CALLBACK_SET_MIC_HOST, value)
def optionmenu_input_mic_device_callback(value):
config.CHOICE_MIC_DEVICE = value
callFunctionIfCallable(config_window.CALLBACK_SET_MIC_DEVICE, value)
def slider_input_mic_energy_threshold_callback(value):
config.INPUT_MIC_ENERGY_THRESHOLD = int(value)
callFunctionIfCallable(config_window.CALLBACK_SET_MIC_ENERGY_THRESHOLD, value)
def checkbox_input_mic_dynamic_energy_threshold_callback(checkbox_box_widget):
print(checkbox_box_widget.get())
config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD = checkbox_box_widget.get()
callFunctionIfCallable(config_window.CALLBACK_SET_MIC_DYNAMIC_ENERGY_THRESHOLD, checkbox_box_widget.get())
def entry_input_mic_record_timeout_callback(value):
print(int(value))
config.INPUT_MIC_RECORD_TIMEOUT = int(value)
callFunctionIfCallable(config_window.CALLBACK_SET_MIC_RECORD_TIMEOUT, value)
def entry_input_mic_phrase_timeout_callback(value):
print(int(value))
config.INPUT_MIC_PHRASE_TIMEOUT = int(value)
callFunctionIfCallable(config_window.CALLBACK_SET_MIC_PHRASE_TIMEOUT, value)
def entry_input_mic_max_phrases_callback(value):
print(int(value))
config.INPUT_MIC_MAX_PHRASES = int(value)
callFunctionIfCallable(config_window.CALLBACK_SET_MIC_MAX_PHRASES, value)
def entry_input_mic_word_filters_callback(value):
word_filter = str(value)
word_filter = [w.strip() for w in word_filter.split(",") if len(w.strip()) > 0]
word_filter = ",".join(word_filter)
print(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()
callFunctionIfCallable(config_window.CALLBACK_SET_MIC_WORD_FILTER, value)
row=0

View File

@@ -2,6 +2,7 @@ from time import sleep
from customtkinter import StringVar, IntVar
from utils import callFunctionIfCallable
from .._SettingBoxGenerator import _SettingBoxGenerator
@@ -39,27 +40,23 @@ def createSettingBox_Speaker(setting_box_wrapper, config_window, settings):
passive_button_wrapper_widget.grid()
def optionmenu_input_speaker_device_callback(value):
config.CHOICE_SPEAKER_DEVICE = value
callFunctionIfCallable(config_window.CALLBACK_SET_SPEAKER_DEVICE, value)
def slider_input_speaker_energy_threshold_callback(value):
config.INPUT_SPEAKER_ENERGY_THRESHOLD = int(value)
callFunctionIfCallable(config_window.CALLBACK_SET_SPEAKER_ENERGY_THRESHOLD, value)
def checkbox_input_speaker_dynamic_energy_threshold_callback(checkbox_box_widget):
print(checkbox_box_widget.get())
config.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = checkbox_box_widget.get()
callFunctionIfCallable(config_window.CALLBACK_SET_SPEAKER_DYNAMIC_ENERGY_THRESHOLD, checkbox_box_widget.get())
def entry_input_speaker_record_timeout_callback(value):
print(int(value))
config.INPUT_SPEAKER_RECORD_TIMEOUT = int(value)
callFunctionIfCallable(config_window.CALLBACK_SET_SPEAKER_RECORD_TIMEOUT, value)
def entry_input_speaker_phrase_timeout_callback(value):
print(int(value))
config.INPUT_SPEAKER_PHRASE_TIMEOUT = int(value)
callFunctionIfCallable(config_window.CALLBACK_SET_SPEAKER_PHRASE_TIMEOUT, value)
def entry_input_speaker_max_phrases_callback(value):
print(int(value))
config.INPUT_SPEAKER_MAX_PHRASES = int(value)
callFunctionIfCallable(config_window.CALLBACK_SET_SPEAKER_MAX_PHRASES, value)

View File

@@ -2,6 +2,7 @@ from time import sleep
from customtkinter import StringVar, IntVar
from utils import callFunctionIfCallable
from .._SettingBoxGenerator import _SettingBoxGenerator
@@ -13,14 +14,7 @@ def createSettingBox_Translation(setting_box_wrapper, config_window, settings):
def deepl_authkey_callback(value):
print(str(value))
# config.AUTH_KEYS["DeepL(auth)"] = str(value)
# 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
callFunctionIfCallable(config_window.CALLBACK_SET_DEEPL_AUTHKEY, value)
row=0