Merge branch 'config_window' into UI_2.0

This commit is contained in:
Sakamoto Shiina
2023-08-29 19:57:05 +09:00
12 changed files with 326 additions and 400 deletions

View File

@@ -6,7 +6,7 @@ from .addConfigSideMenuItem import addConfigSideMenuItem
from .createSettingBoxContainer import createSettingBoxContainer from .createSettingBoxContainer import createSettingBoxContainer
from .setting_box_containers import createSettingBox_Appearance, createSettingBox_Mic from .setting_box_containers import createSettingBox_Appearance, createSettingBox_Mic, createSettingBox_Speaker, createSettingBox_Others, createSettingBox_AdvancedSettings
def createSideMenuAndSettingsBoxContainers(config_window, settings): def createSideMenuAndSettingsBoxContainers(config_window, settings):
@@ -77,34 +77,35 @@ def createSideMenuAndSettingsBoxContainers(config_window, settings):
"setting_box_container_attr_name": "setting_box_container_transcription", "setting_box_container_attr_name": "setting_box_container_transcription",
"setting_boxes": [ "setting_boxes": [
{ "section_title": "Mic", "setting_box": createSettingBox_Mic }, { "section_title": "Mic", "setting_box": createSettingBox_Mic },
] { "section_title": "Speaker", "setting_box": createSettingBox_Speaker },
},
"activate_by_default": True,
},
{
"side_menu_tab_attr_name": "side_menu_tab_parameters",
"label_attr_name": "label_parameters",
"selected_mark_attr_name": "selected_mark_foreground",
"text": "Parameters",
"setting_box_container_settings": {
"setting_box_container_attr_name": "setting_box_container_parameters",
"setting_boxes": [
{ "section_title": None, "setting_box": None },
] ]
}, },
}, },
{ {
"side_menu_tab_attr_name": "side_menu_tab_others", "side_menu_tab_attr_name": "side_menu_tab_others",
"label_attr_name": "label_others", "label_attr_name": "label_others",
"selected_mark_attr_name": "selected_mark_foreground", "selected_mark_attr_name": "selected_mark_others",
"text": "Others", "text": "Others",
"setting_box_container_settings": { "setting_box_container_settings": {
"setting_box_container_attr_name": "setting_box_container_others", "setting_box_container_attr_name": "setting_box_container_others",
"setting_boxes": [ "setting_boxes": [
{ "section_title": None, "setting_box": None }, { "section_title": None, "setting_box": createSettingBox_Others },
] ]
}, },
}, },
{
"side_menu_tab_attr_name": "side_menu_tab_advanced",
"label_attr_name": "label_advanced",
"selected_mark_attr_name": "selected_mark_advanced",
"text": "Advanced Settings",
"setting_box_container_settings": {
"setting_box_container_attr_name": "setting_box_container_advanced",
"setting_boxes": [
{ "section_title": None, "setting_box": createSettingBox_AdvancedSettings },
]
},
"activate_by_default": True,
},
] ]
all_side_menu_tab_attr_name = [item["side_menu_tab_attr_name"] for item in side_menu_and_setting_box_containers_settings] all_side_menu_tab_attr_name = [item["side_menu_tab_attr_name"] for item in side_menu_and_setting_box_containers_settings]

View File

@@ -1,2 +1,4 @@
from .setting_box_appearance import createSettingBox_Appearance from .setting_box_appearance import createSettingBox_Appearance
from .setting_box_transcription import createSettingBox_Mic from .setting_box_transcription import createSettingBox_Mic, createSettingBox_Speaker
from .setting_box_others import createSettingBox_Others
from .setting_box_advanced_settings import createSettingBox_AdvancedSettings

View File

@@ -1,225 +0,0 @@
from time import sleep
from customtkinter import StringVar, IntVar
from .SettingBoxGenerator import SettingBoxGenerator
from config import config
def __tmp(setting_box_wrapper, config_window, settings):
sbg = SettingBoxGenerator(config_window, settings)
createSettingBoxDropdownMenu = sbg.createSettingBoxDropdownMenu
createSettingBoxSwitch = sbg.createSettingBoxSwitch
createSettingBoxCheckbox = sbg.createSettingBoxCheckbox
createSettingBoxSlider = sbg.createSettingBoxSlider
createSettingBoxProgressbarXSlider = sbg.createSettingBoxProgressbarXSlider
createSettingBoxEntry = sbg.createSettingBoxEntry
def checkbox_input_speaker_threshold_check_callback(e, passive_button_wrapper_widget, active_button_wrapper_widget, is_turned_on):
print("is_turned_on", is_turned_on)
if is_turned_on is True:
passive_button_widget = passive_button_wrapper_widget.children["!ctklabel"]
passive_button_wrapper_widget.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR)
passive_button_widget.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR)
passive_button_wrapper_widget.update_idletasks()
sleep(1)
passive_button_wrapper_widget.grid_remove()
active_button_wrapper_widget.grid()
elif is_turned_on is False:
# active_button_widget = active_button_wrapper_widget.children["!ctklabel"]
# active_button_wrapper_widget.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR)
# active_button_widget.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR)
# active_button_wrapper_widget.update_idletasks()
# sleep(3)
active_button_wrapper_widget.grid_remove()
passive_button_wrapper_widget.grid()
# def slider_input_speaker_energy_threshold_callback(self, value):
# config_window.INPUT_SPEAKER_ENERGY_THRESHOLD = int(value)
def set_input_threshold(value):
print(value)
config.INPUT_SPEAKER_ENERGY_THRESHOLD = value
print(config.INPUT_SPEAKER_ENERGY_THRESHOLD)
def dropdownMenuFun(selected_value, optionmenu_widget, dropdown_menu_widget):
print(selected_value)
config.INPUT_SOURCE_LANG = selected_value
def switchFun(_, switch_box_widget):
print(switch_box_widget.get())
def checkboxFun(_, checkbox_box_widget):
print(checkbox_box_widget.get())
def sliderFun(_, value, slider_widget):
print(value)
def entryFun(e, entry_widget):
print(e.widget.get())
config_window.INPUT_MIC_PHRASE_TIMEOUT = int(e.widget.get())
print(config_window.INPUT_MIC_PHRASE_TIMEOUT)
row=0
config_window.sb__dropdown_menu_1 = createSettingBoxDropdownMenu(
parent_widget=setting_box_wrapper,
label_text="Option Menu",
desc_text="Select your preferences from the options menu.\nYou can choose your preferred language.",
optionmenu_attr_name="optionmenu_attr_name_1",
dropdown_menu_attr_name="dropdown_menu_attr_name_1",
dropdown_menu_values=["tt", "Japanese", "English"],
command=lambda value: dropdownMenuFun(value, config_window.optionmenu_attr_name_1, config_window.dropdown_menu_attr_name_1),
variable=StringVar(value=config.INPUT_SOURCE_LANG)
)
config_window.sb__dropdown_menu_1.grid(row=row)
row+=1
config_window.sb__dropdown_menu_2 = createSettingBoxDropdownMenu(
parent_widget=setting_box_wrapper,
label_text="Option Menu",
desc_text="Select your preferences from the options menu.\nYou can choose your preferred language.",
optionmenu_attr_name="optionmenu_attr_name_2",
dropdown_menu_attr_name="dropdown_menu_attr_name_1",
dropdown_menu_values=["tt", "Japanese", "English"],
command=lambda value: dropdownMenuFun(value, config_window.optionmenu_attr_name_2, config_window.dropdown_menu_attr_name_1),
variable=StringVar(value=config.INPUT_SOURCE_LANG)
)
config_window.sb__dropdown_menu_2.grid(row=row)
row+=1
config_window.sb__switch_1 = createSettingBoxSwitch(
parent_widget=setting_box_wrapper,
label_text="Switch",
desc_text="Turning this switch on will bring happiness.\nAs for turning it off... I leave that to your imagination",
switch_attr_name="switch_attr_name_1",
command=lambda: switchFun(config_window.switch_attr_name_1),
is_checked=True,
)
config_window.sb__switch_1.grid(row=row)
row+=1
config_window.sb__checkbox_1 = createSettingBoxCheckbox(
parent_widget=setting_box_wrapper,
label_text="Checkbox",
desc_text="Checkbox ticked, a checkmark.",
checkbox_attr_name="checkbox_attr_name_1",
command=lambda: checkboxFun(config_window.checkbox_attr_name_1),
is_checked=False,
)
config_window.sb__checkbox_1.grid(row=row)
row+=1
config_window.sb__slider_1 = createSettingBoxSlider(
parent_widget=setting_box_wrapper,
label_text="Slider",
desc_text="Adjust using the slider; the balance is up to you.",
slider_attr_name="slider_attr_name_1",
slider_range=(0, config_window.MAX_SPEAKER_ENERGY_THRESHOLD),
slider_number_of_steps=config_window.MAX_SPEAKER_ENERGY_THRESHOLD,
command=lambda value: sliderFun(value, config_window.slider_attr_name_1),
variable=IntVar(value=config_window.INPUT_SPEAKER_ENERGY_THRESHOLD),
)
config_window.sb__slider_1.grid(row=row)
row+=1
config_window.sb__progressbar_x_slider_1 = createSettingBoxProgressbarXSlider(
parent_widget=setting_box_wrapper,
label_text="Progressbar and Slider for check the threshold",
desc_text="just the slider to modify the threshold for activating voice input.\nPress the microphone button to start input, and you can adjust it while monitoring the actual volume.",
command=set_input_threshold, # ?
variable=IntVar(value=config.INPUT_MIC_ENERGY_THRESHOLD),
entry_attr_name="progressbar_x_slider__entry_attr_name_1",
slider_attr_name="progressbar_x_slider__slider_attr_name_1",
slider_range=(0, config_window.MAX_SPEAKER_ENERGY_THRESHOLD),
slider_number_of_steps=config_window.MAX_SPEAKER_ENERGY_THRESHOLD,
progressbar_attr_name="progressbar_x_slider__progressbar_attr_name_1",
passive_button_attr_name="progressbar_x_slider__passive_button_attr_name_1",
passive_button_command=lambda e: checkbox_input_speaker_threshold_check_callback(
e,
config_window.progressbar_x_slider__passive_button_attr_name_1,
config_window.progressbar_x_slider__active_button_attr_name_1,
is_turned_on=True,
),
active_button_attr_name="progressbar_x_slider__active_button_attr_name_1",
active_button_command=lambda e: checkbox_input_speaker_threshold_check_callback(
e,
config_window.progressbar_x_slider__passive_button_attr_name_1,
config_window.progressbar_x_slider__active_button_attr_name_1,
is_turned_on=False,
),
button_image_filename="mic_icon_white.png"
)
config_window.sb__progressbar_x_slider_1.grid(row=row)
row+=1
config_window.sb__progressbar_x_slider_2 = createSettingBoxProgressbarXSlider(
parent_widget=setting_box_wrapper,
label_text="Progressbar and Slider for check the threshold2",
desc_text="just the slider to modify the threshold for activating voice input.\nPress the microphone button to start input, and you can adjust it while monitoring the actual volume.",
command=set_input_threshold, # ?
variable=IntVar(value=config.INPUT_SPEAKER_ENERGY_THRESHOLD),
entry_attr_name="progressbar_x_slider__entry_attr_name_2",
slider_attr_name="progressbar_x_slider__slider_attr_name_2",
slider_range=(0, config_window.MAX_SPEAKER_ENERGY_THRESHOLD),
slider_number_of_steps=config_window.MAX_SPEAKER_ENERGY_THRESHOLD,
progressbar_attr_name="progressbar_x_slider__progressbar_attr_name_2",
passive_button_attr_name="progressbar_x_slider__passive_button_attr_name_2",
passive_button_command=lambda e: checkbox_input_speaker_threshold_check_callback(
e,
config_window.progressbar_x_slider__passive_button_attr_name_2,
config_window.progressbar_x_slider__active_button_attr_name_2,
is_turned_on=True,
),
active_button_attr_name="progressbar_x_slider__active_button_attr_name_2",
active_button_command=lambda e: checkbox_input_speaker_threshold_check_callback(
e,
config_window.progressbar_x_slider__passive_button_attr_name_2,
config_window.progressbar_x_slider__active_button_attr_name_2,
is_turned_on=False,
),
button_image_filename="headphones_icon_white.png"
)
config_window.sb__progressbar_x_slider_2.grid(row=row)
row+=1
config_window.sb__entry_1 = createSettingBoxEntry(
parent_widget=setting_box_wrapper,
label_text="Entry",
desc_text="Please input a numerical value.",
entry_attr_name="entry_attr_name_1",
entry_width=settings.uism.SB__ENTRY_WIDTH_100,
entry_bind__Any_KeyRelease=lambda value: entryFun(value, config_window.entry_attr_name_1),
entry_textvariable=IntVar(value=config_window.INPUT_MIC_PHRASE_TIMEOUT),
)
config_window.sb__entry_1.grid(row=row, pady=0)
row+=1

View File

@@ -0,0 +1 @@
from .createSettingBox_AdvancedSettings import createSettingBox_AdvancedSettings

View File

@@ -0,0 +1,48 @@
from time import sleep
from customtkinter import StringVar, IntVar
from ..SettingBoxGenerator import SettingBoxGenerator
from config import config
def createSettingBox_AdvancedSettings(setting_box_wrapper, config_window, settings):
sbg = SettingBoxGenerator(config_window, settings)
createSettingBoxEntry = sbg.createSettingBoxEntry
def entry_ip_address_callback(value):
config.OSC_IP_ADDRESS = str(value)
def entry_port_callback(value):
config.OSC_PORT = int(value)
row=0
config_window.sb__ip_address = createSettingBoxEntry(
parent_widget=setting_box_wrapper,
label_text="OSC IP Address",
desc_text="(Default: 127.0.0.1)",
entry_attr_name="sb__entry_ip_address",
entry_width=settings.uism.SB__ENTRY_WIDTH_150,
entry_bind__Any_KeyRelease=lambda value: entry_ip_address_callback(value),
entry_textvariable=StringVar(value=config.OSC_IP_ADDRESS),
)
config_window.sb__ip_address.grid(row=row)
row+=1
config_window.sb__port = createSettingBoxEntry(
parent_widget=setting_box_wrapper,
label_text="OSC Port",
desc_text="(Default: 9000)",
entry_attr_name="sb__entry_port",
entry_width=settings.uism.SB__ENTRY_WIDTH_150,
entry_bind__Any_KeyRelease=lambda value: entry_port_callback(value),
entry_textvariable=IntVar(value=config.OSC_PORT),
)
config_window.sb__port.grid(row=row)
row+=1

View File

@@ -59,8 +59,8 @@ def createSettingBox_Appearance(setting_box_wrapper, config_window, settings):
parent_widget=setting_box_wrapper, parent_widget=setting_box_wrapper,
label_text="Theme", label_text="Theme",
desc_text="Change the color theme from \"Light\" and \"Dark\". If you select \"System\", It will adjust based on your Windows theme. (Default: System)", desc_text="Change the color theme from \"Light\" and \"Dark\". If you select \"System\", It will adjust based on your Windows theme. (Default: System)",
optionmenu_attr_name="sb__appearance_theme_optionmenu", optionmenu_attr_name="sb__optionmenu_appearance_theme",
dropdown_menu_attr_name="sb__appearance_theme_dropdown", dropdown_menu_attr_name="sb__dropdown_appearance_theme",
dropdown_menu_values=["Light", "Dark", "System"], dropdown_menu_values=["Light", "Dark", "System"],
command=lambda value: optionmenu_appearance_theme_callback(value), command=lambda value: optionmenu_appearance_theme_callback(value),
variable=StringVar(value=config.APPEARANCE_THEME) variable=StringVar(value=config.APPEARANCE_THEME)
@@ -73,8 +73,8 @@ def createSettingBox_Appearance(setting_box_wrapper, config_window, settings):
parent_widget=setting_box_wrapper, parent_widget=setting_box_wrapper,
label_text="UI Size", label_text="UI Size",
desc_text="(Default: 100%)", desc_text="(Default: 100%)",
optionmenu_attr_name="sb__ui_scaling_optionmenu", optionmenu_attr_name="sb__optionmenu_ui_scaling",
dropdown_menu_attr_name="sb__ui_scaling_dropdown", dropdown_menu_attr_name="sb__dropdown_ui_scaling",
dropdown_menu_values=["80%", "90%", "100%", "110%", "120%"], dropdown_menu_values=["80%", "90%", "100%", "110%", "120%"],
command=lambda value: optionmenu_ui_scaling_callback(value), command=lambda value: optionmenu_ui_scaling_callback(value),
variable=StringVar(value=config.UI_SCALING) variable=StringVar(value=config.UI_SCALING)
@@ -88,8 +88,8 @@ def createSettingBox_Appearance(setting_box_wrapper, config_window, settings):
parent_widget=setting_box_wrapper, parent_widget=setting_box_wrapper,
label_text="Font Family", label_text="Font Family",
desc_text="(Default: Yu Gothic UI)", desc_text="(Default: Yu Gothic UI)",
optionmenu_attr_name="sb__font_family_optionmenu", optionmenu_attr_name="sb__optionmenu_font_family",
dropdown_menu_attr_name="sb__font_family_dropdown", dropdown_menu_attr_name="sb__dropdown_font_family",
dropdown_menu_values=["Font A", "Font B"], dropdown_menu_values=["Font A", "Font B"],
# dropdown_menu_values=font_families, # dropdown_menu_values=font_families,
command=lambda value: optionmenu_font_family_callback(value), command=lambda value: optionmenu_font_family_callback(value),
@@ -104,8 +104,8 @@ def createSettingBox_Appearance(setting_box_wrapper, config_window, settings):
parent_widget=setting_box_wrapper, parent_widget=setting_box_wrapper,
label_text="UI Language", label_text="UI Language",
desc_text="(Default: English)", desc_text="(Default: English)",
optionmenu_attr_name="sb__ui_language_optionmenu", optionmenu_attr_name="sb__optionmenu_ui_language",
dropdown_menu_attr_name="sb__ui_language_dropdown", dropdown_menu_attr_name="sb__dropdown_ui_language",
dropdown_menu_values=selectable_languages_values, dropdown_menu_values=selectable_languages_values,
command=lambda value: optionmenu_ui_language_callback(value), command=lambda value: optionmenu_ui_language_callback(value),
variable=StringVar(value=selectable_languages[config.UI_LANGUAGE]), variable=StringVar(value=selectable_languages[config.UI_LANGUAGE]),

View File

@@ -0,0 +1 @@
from .createSettingBox_Others import createSettingBox_Others

View File

@@ -0,0 +1,68 @@
from time import sleep
from customtkinter import StringVar, IntVar
from ..SettingBoxGenerator import SettingBoxGenerator
from config import config
def createSettingBox_Others(setting_box_wrapper, config_window, settings):
sbg = SettingBoxGenerator(config_window, settings)
createSettingBoxCheckbox = sbg.createSettingBoxCheckbox
createSettingBoxEntry = sbg.createSettingBoxEntry
# 関数名 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()
def checkbox_notice_xsoverlay_callback(checkbox_box_widget):
print(checkbox_box_widget.get())
config.ENABLE_NOTICE_XSOVERLAY = checkbox_box_widget.get()
def entry_message_format_callback(value):
if len(value) > 0:
config.MESSAGE_FORMAT = value
row=0
config_window.sb__auto_clear_chatbox = createSettingBoxCheckbox(
parent_widget=setting_box_wrapper,
label_text="Auto Clear The Message Box",
desc_text="Clear the message box after sending your message.",
checkbox_attr_name="sb__checkbox_auto_clear_chatbox",
command=lambda: checkbox_auto_clear_chatbox_callback(config_window.sb__checkbox_auto_clear_chatbox),
is_checked=False
)
config_window.sb__auto_clear_chatbox.grid(row=row)
row+=1
config_window.sb__notice_xsoverlay = createSettingBoxCheckbox(
parent_widget=setting_box_wrapper,
label_text="Notification XSOverlay (VR Only)",
desc_text="Notify received messages by using XSOverlay's notification feature.",
checkbox_attr_name="sb__checkbox_notice_xsoverlay",
command=lambda: checkbox_notice_xsoverlay_callback(config_window.sb__checkbox_notice_xsoverlay),
is_checked=False
)
config_window.sb__notice_xsoverlay.grid(row=row)
row+=1
config_window.sb__message_format = createSettingBoxEntry(
parent_widget=setting_box_wrapper,
label_text="Message Format",
desc_text="You can change the decoration of the message you want to send. (Default: \"[message]([translation])\" )",
entry_attr_name="sb__entry_message_format",
entry_width=settings.uism.SB__ENTRY_WIDTH_250,
entry_bind__Any_KeyRelease=lambda value: entry_message_format_callback(value),
entry_textvariable=StringVar(value=config.MESSAGE_FORMAT),
)
config_window.sb__message_format.grid(row=row)
row+=1

View File

@@ -1 +1,2 @@
from .createSettingBox_Mic import createSettingBox_Mic from .createSettingBox_Mic import createSettingBox_Mic
from .createSettingBox_Speaker import createSettingBox_Speaker

View File

@@ -13,31 +13,11 @@ def createSettingBox_Mic(setting_box_wrapper, config_window, settings):
sbg = SettingBoxGenerator(config_window, settings) sbg = SettingBoxGenerator(config_window, settings)
createSettingBoxDropdownMenu = sbg.createSettingBoxDropdownMenu createSettingBoxDropdownMenu = sbg.createSettingBoxDropdownMenu
createSettingBoxSwitch = sbg.createSettingBoxSwitch
createSettingBoxCheckbox = sbg.createSettingBoxCheckbox createSettingBoxCheckbox = sbg.createSettingBoxCheckbox
createSettingBoxSlider = sbg.createSettingBoxSlider
createSettingBoxProgressbarXSlider = sbg.createSettingBoxProgressbarXSlider createSettingBoxProgressbarXSlider = sbg.createSettingBoxProgressbarXSlider
createSettingBoxEntry = sbg.createSettingBoxEntry createSettingBoxEntry = sbg.createSettingBoxEntry
# def dropdownMenuFun(selected_value):
# print(selected_value)
# config.INPUT_SOURCE_LANG = selected_value
# def switchFun(_, switch_box_widget):
# print(switch_box_widget.get())
# def checkboxFun(_, checkbox_box_widget):
# print(checkbox_box_widget.get())
# def sliderFun(value):
# print(value)
# def entryFun(value):
# config_window.INPUT_MIC_PHRASE_TIMEOUT = int(value)
# print(config_window.INPUT_MIC_PHRASE_TIMEOUT)
def checkbox_input_speaker_threshold_check_callback(e, passive_button_wrapper_widget, active_button_wrapper_widget, is_turned_on): def checkbox_input_speaker_threshold_check_callback(e, passive_button_wrapper_widget, active_button_wrapper_widget, is_turned_on):
print("is_turned_on", is_turned_on) print("is_turned_on", is_turned_on)
@@ -81,11 +61,11 @@ def createSettingBox_Mic(setting_box_wrapper, config_window, settings):
def entry_input_mic_phrase_timeout_callback(value): def entry_input_mic_phrase_timeout_callback(value):
print(int(value)) print(int(value))
config.INPUT_MIC_RECORD_TIMEOUT = int(value) config.INPUT_MIC_PHRASE_TIMEOUT = int(value)
def entry_input_mic_max_phrases_callback(value): def entry_input_mic_max_phrases_callback(value):
print(str(value)) print(int(value))
config.INPUT_MIC_MAX_PHRASES = str(value) config.INPUT_MIC_MAX_PHRASES = int(value)
def entry_input_mic_word_filters_callback(value): def entry_input_mic_word_filters_callback(value):
word_filter = str(value) word_filter = str(value)
@@ -106,8 +86,8 @@ def createSettingBox_Mic(setting_box_wrapper, config_window, settings):
parent_widget=setting_box_wrapper, parent_widget=setting_box_wrapper,
label_text="Mic Host", label_text="Mic Host",
desc_text="Select the mic host. (Default: ?)", desc_text="Select the mic host. (Default: ?)",
optionmenu_attr_name="sb__mic_host_optionmenu", optionmenu_attr_name="sb__optionmenu_mic_host",
dropdown_menu_attr_name="sb__mic_host_dropdown", dropdown_menu_attr_name="sb__dropdown_mic_host",
# dropdown_menu_values=model.getListInputHost(), # dropdown_menu_values=model.getListInputHost(),
dropdown_menu_values=["host1", "host2", "host3"], dropdown_menu_values=["host1", "host2", "host3"],
command=lambda value: optionmenu_mic_host_callback(value), command=lambda value: optionmenu_mic_host_callback(value),
@@ -119,9 +99,9 @@ def createSettingBox_Mic(setting_box_wrapper, config_window, settings):
config_window.sb__mic_device = createSettingBoxDropdownMenu( config_window.sb__mic_device = createSettingBoxDropdownMenu(
parent_widget=setting_box_wrapper, parent_widget=setting_box_wrapper,
label_text="Mic Device", label_text="Mic Device",
desc_text="Select the mic host. (Default: ?)", desc_text="Select the mic devise. (Default: ?)",
optionmenu_attr_name="sb__mic_device_optionmenu", optionmenu_attr_name="sb__optionmenu_mic_device",
dropdown_menu_attr_name="sb__mic_device_dropdown", dropdown_menu_attr_name="sb__dropdown_mic_device",
# dropdown_menu_values=model.getListInputDevice(), # dropdown_menu_values=model.getListInputDevice(),
dropdown_menu_values=["device1", "device2", "device3"], dropdown_menu_values=["device1", "device2", "device3"],
command=lambda value: optionmenu_input_mic_device_callback(value), command=lambda value: optionmenu_input_mic_device_callback(value),
@@ -232,123 +212,4 @@ def createSettingBox_Mic(setting_box_wrapper, config_window, settings):
entry_textvariable=entry_textvariable, entry_textvariable=entry_textvariable,
) )
config_window.sb__mic_word_filter.grid(row=row) config_window.sb__mic_word_filter.grid(row=row)
row+=1 row+=1
# config_window.sb__switch_1 = createSettingBoxSwitch(
# parent_widget=setting_box_wrapper,
# label_text="Switch",
# desc_text="Turning this switch on will bring happiness.\nAs for turning it off... I leave that to your imagination",
# switch_attr_name="switch_attr_name_1",
# command=lambda: switchFun(config_window.switch_attr_name_1),
# is_checked=True,
# )
# config_window.sb__switch_1.grid(row=row)
# row+=1
# config_window.sb__checkbox_1 = createSettingBoxCheckbox(
# parent_widget=setting_box_wrapper,
# label_text="Checkbox",
# desc_text="Checkbox ticked, a checkmark.",
# checkbox_attr_name="checkbox_attr_name_1",
# command=lambda: checkboxFun(config_window.checkbox_attr_name_1),
# is_checked=False,
# )
# config_window.sb__checkbox_1.grid(row=row)
# row+=1
# config_window.sb__slider_1 = createSettingBoxSlider(
# parent_widget=setting_box_wrapper,
# label_text="Slider",
# desc_text="Adjust using the slider; the balance is up to you.",
# slider_attr_name="slider_attr_name_1",
# slider_range=(0, config_window.MAX_SPEAKER_ENERGY_THRESHOLD),
# slider_number_of_steps=config_window.MAX_SPEAKER_ENERGY_THRESHOLD,
# command=lambda value: sliderFun(value, config_window.slider_attr_name_1),
# variable=IntVar(value=config_window.INPUT_SPEAKER_ENERGY_THRESHOLD),
# )
# config_window.sb__slider_1.grid(row=row)
# row+=1
# config_window.sb__progressbar_x_slider_1 = createSettingBoxProgressbarXSlider(
# parent_widget=setting_box_wrapper,
# label_text="Progressbar and Slider for check the threshold",
# desc_text="just the slider to modify the threshold for activating voice input.\nPress the microphone button to start input, and you can adjust it while monitoring the actual volume.",
# command=set_input_threshold, # ?
# variable=IntVar(value=config.INPUT_MIC_ENERGY_THRESHOLD),
# entry_attr_name="progressbar_x_slider__entry_attr_name_1",
# slider_attr_name="progressbar_x_slider__slider_attr_name_1",
# slider_range=(0, config_window.MAX_SPEAKER_ENERGY_THRESHOLD),
# slider_number_of_steps=config_window.MAX_SPEAKER_ENERGY_THRESHOLD,
# progressbar_attr_name="progressbar_x_slider__progressbar_attr_name_1",
# passive_button_attr_name="progressbar_x_slider__passive_button_attr_name_1",
# passive_button_command=lambda e: checkbox_input_speaker_threshold_check_callback(
# e,
# config_window.progressbar_x_slider__passive_button_attr_name_1,
# config_window.progressbar_x_slider__active_button_attr_name_1,
# is_turned_on=True,
# ),
# active_button_attr_name="progressbar_x_slider__active_button_attr_name_1",
# active_button_command=lambda e: checkbox_input_speaker_threshold_check_callback(
# e,
# config_window.progressbar_x_slider__passive_button_attr_name_1,
# config_window.progressbar_x_slider__active_button_attr_name_1,
# is_turned_on=False,
# ),
# button_image_filename="mic_icon_white.png"
# )
# config_window.sb__progressbar_x_slider_1.grid(row=row)
# row+=1
# config_window.sb__progressbar_x_slider_2 = createSettingBoxProgressbarXSlider(
# parent_widget=setting_box_wrapper,
# label_text="Progressbar and Slider for check the threshold2",
# desc_text="just the slider to modify the threshold for activating voice input.\nPress the microphone button to start input, and you can adjust it while monitoring the actual volume.",
# command=set_input_threshold, # ?
# variable=IntVar(value=config.INPUT_SPEAKER_ENERGY_THRESHOLD),
# entry_attr_name="progressbar_x_slider__entry_attr_name_2",
# slider_attr_name="progressbar_x_slider__slider_attr_name_2",
# slider_range=(0, config_window.MAX_SPEAKER_ENERGY_THRESHOLD),
# slider_number_of_steps=config_window.MAX_SPEAKER_ENERGY_THRESHOLD,
# progressbar_attr_name="progressbar_x_slider__progressbar_attr_name_2",
# passive_button_attr_name="progressbar_x_slider__passive_button_attr_name_2",
# passive_button_command=lambda e: checkbox_input_speaker_threshold_check_callback(
# e,
# config_window.progressbar_x_slider__passive_button_attr_name_2,
# config_window.progressbar_x_slider__active_button_attr_name_2,
# is_turned_on=True,
# ),
# active_button_attr_name="progressbar_x_slider__active_button_attr_name_2",
# active_button_command=lambda e: checkbox_input_speaker_threshold_check_callback(
# e,
# config_window.progressbar_x_slider__passive_button_attr_name_2,
# config_window.progressbar_x_slider__active_button_attr_name_2,
# is_turned_on=False,
# ),
# button_image_filename="headphones_icon_white.png"
# )
# config_window.sb__progressbar_x_slider_2.grid(row=row)
# row+=1
# config_window.sb__entry_1 = createSettingBoxEntry(
# parent_widget=setting_box_wrapper,
# label_text="Entry",
# desc_text="Please input a numerical value.",
# entry_attr_name="entry_attr_name_1",
# entry_width=settings.uism.SB__ENTRY_WIDTH_100,
# entry_bind__Any_KeyRelease=lambda value: entryFun(value, config_window.entry_attr_name_1),
# entry_textvariable=IntVar(value=config_window.INPUT_MIC_PHRASE_TIMEOUT),
# )
# config_window.sb__entry_1.grid(row=row, pady=0)
# row+=1

View File

@@ -0,0 +1,168 @@
from time import sleep
from customtkinter import StringVar, IntVar
from ..SettingBoxGenerator import SettingBoxGenerator
from config import config
def createSettingBox_Speaker(setting_box_wrapper, config_window, settings):
sbg = SettingBoxGenerator(config_window, settings)
createSettingBoxDropdownMenu = sbg.createSettingBoxDropdownMenu
createSettingBoxCheckbox = sbg.createSettingBoxCheckbox
createSettingBoxProgressbarXSlider = sbg.createSettingBoxProgressbarXSlider
createSettingBoxEntry = sbg.createSettingBoxEntry
def checkbox_input_speaker_threshold_check_callback(e, passive_button_wrapper_widget, active_button_wrapper_widget, is_turned_on):
print("is_turned_on", is_turned_on)
if is_turned_on is True:
passive_button_widget = passive_button_wrapper_widget.children["!ctklabel"]
passive_button_wrapper_widget.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR)
passive_button_widget.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR)
passive_button_wrapper_widget.update_idletasks()
sleep(1)
passive_button_wrapper_widget.grid_remove()
active_button_wrapper_widget.grid()
elif is_turned_on is False:
# active_button_widget = active_button_wrapper_widget.children["!ctklabel"]
# active_button_wrapper_widget.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR)
# active_button_widget.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR)
# active_button_wrapper_widget.update_idletasks()
# sleep(3)
active_button_wrapper_widget.grid_remove()
passive_button_wrapper_widget.grid()
def optionmenu_input_speaker_device_callback(value):
config.CHOICE_SPEAKER_DEVICE = value
def slider_input_speaker_energy_threshold_callback(value):
config.INPUT_SPEAKER_ENERGY_THRESHOLD = int(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()
def entry_input_speaker_record_timeout_callback(value):
print(int(value))
config.INPUT_SPEAKER_RECORD_TIMEOUT = int(value)
def entry_input_speaker_phrase_timeout_callback(value):
print(int(value))
config.INPUT_SPEAKER_PHRASE_TIMEOUT = int(value)
def entry_input_speaker_max_phrases_callback(value):
print(int(value))
config.INPUT_SPEAKER_MAX_PHRASES = int(value)
row=0
config_window.sb__speaker_device = createSettingBoxDropdownMenu(
parent_widget=setting_box_wrapper,
label_text="Speaker Device",
desc_text="Select the speaker devise. (Default: ?)",
optionmenu_attr_name="sb__optionmenu_speaker_device",
dropdown_menu_attr_name="sb__dropdown_speaker_device",
# dropdown_menu_values=model.getListOutputDevice(),
dropdown_menu_values=["device1", "device2", "device3"],
command=lambda value: optionmenu_input_speaker_device_callback(value),
variable=StringVar(value=config.CHOICE_SPEAKER_DEVICE)
)
config_window.sb__speaker_device.grid(row=row)
row+=1
config_window.sb__speaker_energy_threshold = createSettingBoxProgressbarXSlider(
parent_widget=setting_box_wrapper,
label_text="Speaker Energy Threshold",
desc_text="Slider to modify the threshold for activating voice input.\nPress the headphones mark button to start input and speak something, so you can adjust it while monitoring the actual volume. 0 to 4000 (Default: 300)",
command=slider_input_speaker_energy_threshold_callback,
variable=IntVar(value=config.INPUT_SPEAKER_ENERGY_THRESHOLD),
entry_attr_name="sb__progressbar_x_slider__entry_speaker_energy_threshold",
slider_attr_name="progressbar_x_slider__slider_speaker_energy_threshold",
slider_range=(0, config.MAX_SPEAKER_ENERGY_THRESHOLD),
slider_number_of_steps=config.MAX_SPEAKER_ENERGY_THRESHOLD,
progressbar_attr_name="sb__progressbar_x_slider__progressbar_speaker_energy_threshold",
passive_button_attr_name="sb__progressbar_x_slider__passive_button_speaker_energy_threshold",
passive_button_command=lambda e: checkbox_input_speaker_threshold_check_callback(
e,
config_window.sb__progressbar_x_slider__passive_button_speaker_energy_threshold,
config_window.sb__progressbar_x_slider__active_button_speaker_energy_threshold,
is_turned_on=True,
),
active_button_attr_name="sb__progressbar_x_slider__active_button_speaker_energy_threshold",
active_button_command=lambda e: checkbox_input_speaker_threshold_check_callback(
e,
config_window.sb__progressbar_x_slider__passive_button_speaker_energy_threshold,
config_window.sb__progressbar_x_slider__active_button_speaker_energy_threshold,
is_turned_on=False,
),
button_image_filename="headphones_icon_white.png"
)
config_window.sb__speaker_energy_threshold.grid(row=row)
row+=1
# Speaker Dynamic Energy Thresholdも上に引っ付ける予定
config_window.sb__speaker_dynamic_energy_threshold = createSettingBoxCheckbox(
parent_widget=setting_box_wrapper,
label_text="Speaker Dynamic Energy Threshold",
desc_text="When this feature is selected, it will automatically adjust in a way that works well, based on the set Speaker Energy Threshold.",
checkbox_attr_name="sb__checkbox_speaker_dynamic_energy_threshold",
command=lambda: checkbox_input_speaker_dynamic_energy_threshold_callback(config_window.sb__checkbox_speaker_dynamic_energy_threshold),
is_checked=False
)
config_window.sb__speaker_dynamic_energy_threshold.grid(row=row)
row+=1
# 以下3つも一つの項目にまとめるかもしれない
config_window.sb__speaker_record_timeout = createSettingBoxEntry(
parent_widget=setting_box_wrapper,
label_text="Speaker Record Timeout",
desc_text="(Default: 3)",
entry_attr_name="sb__entry_speaker_record_timeout",
entry_width=settings.uism.SB__ENTRY_WIDTH_100,
entry_bind__Any_KeyRelease=lambda value: entry_input_speaker_record_timeout_callback(value),
entry_textvariable=IntVar(value=config.INPUT_SPEAKER_RECORD_TIMEOUT),
)
config_window.sb__speaker_record_timeout.grid(row=row)
row+=1
config_window.sb__speaker_phrase_timeout = createSettingBoxEntry(
parent_widget=setting_box_wrapper,
label_text="Speaker Phrase Timeout",
desc_text="It will stop recording and receive the recordings when the set second(s) is reached. (Default: 3)",
entry_attr_name="sb__entry_speaker_phrase_timeout",
entry_width=settings.uism.SB__ENTRY_WIDTH_100,
entry_bind__Any_KeyRelease=lambda value: entry_input_speaker_phrase_timeout_callback(value),
entry_textvariable=IntVar(value=config.INPUT_SPEAKER_PHRASE_TIMEOUT),
)
config_window.sb__speaker_phrase_timeout.grid(row=row)
row+=1
config_window.sb__speaker_max_phrases = createSettingBoxEntry(
parent_widget=setting_box_wrapper,
label_text="Speaker Max Phrases",
desc_text="It will stop recording and receive the recordings when the set count of phrase(s) is reached. (Default: 10)",
entry_attr_name="sb__entry_speaker_max_phrases",
entry_width=settings.uism.SB__ENTRY_WIDTH_100,
entry_bind__Any_KeyRelease=lambda value: entry_input_speaker_max_phrases_callback(value),
entry_textvariable=IntVar(value=config.INPUT_SPEAKER_MAX_PHRASES),
)
config_window.sb__speaker_max_phrases.grid(row=row)
row+=1
# __________

View File

@@ -157,7 +157,7 @@ class UiScalingManager():
self.config_window.SB__ENTRY_HEIGHT = self._calculateUiSize(30) self.config_window.SB__ENTRY_HEIGHT = self._calculateUiSize(30)
# SB__ENTRY_WIDTH_10 ... SB__ENTRY_WIDTH_200 # SB__ENTRY_WIDTH_10 ... SB__ENTRY_WIDTH_200
for i in range(10, 201, 10): for i in range(10, 301, 10):
setattr(self.config_window, f'SB__ENTRY_WIDTH_{i}', self._calculateUiSize(i)) setattr(self.config_window, f'SB__ENTRY_WIDTH_{i}', self._calculateUiSize(i))