[Add] New GUI from Shiina
This commit is contained in:
@@ -0,0 +1 @@
|
||||
from .createSideMenuAndSettingsBoxContainers import createSideMenuAndSettingsBoxContainers
|
||||
@@ -0,0 +1,109 @@
|
||||
from customtkinter import CTkFont, CTkFrame, CTkLabel
|
||||
|
||||
from ....ui_utils import bindEnterAndLeaveColor, bindButtonPressColor, bindButtonReleaseFunction, switchActiveTabAndPassiveTab, switchTabsColor
|
||||
|
||||
|
||||
|
||||
def addConfigSideMenuItem(config_window, settings, side_menu_settings, side_menu_row, all_side_menu_tab_attr_name):
|
||||
|
||||
|
||||
def switchActiveAndPassiveSettingBoxContainerTabsColor(target_active_widget):
|
||||
|
||||
setting_box_container_tabs = []
|
||||
for tab_attr_name in all_side_menu_tab_attr_name:
|
||||
tab_attr = getattr(config_window, tab_attr_name)
|
||||
setting_box_container_tabs.append(tab_attr)
|
||||
|
||||
switchTabsColor(
|
||||
target_widget=target_active_widget,
|
||||
tab_buttons=setting_box_container_tabs,
|
||||
active_bg_color=settings.ctm.SIDE_MENU_LABELS_BG_COLOR,
|
||||
active_text_color=settings.ctm.SIDE_MENU_LABELS_SELECTED_TEXT_COLOR,
|
||||
passive_bg_color=settings.ctm.SIDE_MENU_LABELS_BG_COLOR,
|
||||
passive_text_color=settings.ctm.LABELS_TEXT_COLOR
|
||||
)
|
||||
|
||||
for setting_box_container_tab in setting_box_container_tabs:
|
||||
setting_box_container_tab.children["!ctkframe"].place(relx=-1)
|
||||
|
||||
target_active_widget.children["!ctkframe"].place(relx=0)
|
||||
|
||||
|
||||
|
||||
|
||||
def switchSettingBoxContainerTabFunction(target_active_widget):
|
||||
switchActiveAndPassiveSettingBoxContainerTabsColor(target_active_widget)
|
||||
switchActiveTabAndPassiveTab(target_active_widget, config_window.current_active_side_menu_tab, config_window.current_active_side_menu_tab.passive_function, settings.ctm.SIDE_MENU_LABELS_HOVERED_BG_COLOR, settings.ctm.SIDE_MENU_LABELS_CLICKED_BG_COLOR, settings.ctm.SIDE_MENU_LABELS_BG_COLOR)
|
||||
config_window.current_active_side_menu_tab = target_active_widget
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def switchSettingBoxContainer(target_setting_box_container_attr_name):
|
||||
config_window.current_active_setting_box_container.grid_remove()
|
||||
config_window.current_active_setting_box_container = getattr(config_window, target_setting_box_container_attr_name)
|
||||
config_window.current_active_setting_box_container.grid()
|
||||
|
||||
# Move to the top position when the setting box is switched.
|
||||
config_window.main_setting_box_scrollable_container._parent_canvas.yview_moveto("0")
|
||||
|
||||
|
||||
def switchToTargetSettingBoxContainer(e, text, target_active_tab_widget_attr_name, target_setting_box_container_attr_name):
|
||||
print("switchToTargetSettingBoxContainer", target_setting_box_container_attr_name)
|
||||
config_window.main_current_active_config_title.configure(text=text)
|
||||
target_active_tab_widget = getattr(config_window, target_active_tab_widget_attr_name)
|
||||
switchSettingBoxContainerTabFunction(target_active_tab_widget)
|
||||
switchSettingBoxContainer(target_setting_box_container_attr_name)
|
||||
|
||||
|
||||
|
||||
|
||||
side_menu_tab_attr_name = side_menu_settings["side_menu_tab_attr_name"]
|
||||
label_attr_name = side_menu_settings["label_attr_name"]
|
||||
selected_mark_attr_name = side_menu_settings["selected_mark_attr_name"]
|
||||
text = side_menu_settings["text"]
|
||||
setting_box_container_attr_name = side_menu_settings["setting_box_container_settings"]["setting_box_container_attr_name"]
|
||||
command = lambda e: switchToTargetSettingBoxContainer(
|
||||
e=e,
|
||||
text=text,
|
||||
target_active_tab_widget_attr_name=side_menu_tab_attr_name,
|
||||
target_setting_box_container_attr_name=setting_box_container_attr_name,
|
||||
)
|
||||
|
||||
|
||||
# Side menu
|
||||
frame_widget = CTkFrame(config_window.side_menu_container, corner_radius=0, fg_color=settings.ctm.SIDE_MENU_LABELS_BG_COLOR, cursor="hand2", width=0, height=0)
|
||||
setattr(config_window, side_menu_tab_attr_name, frame_widget)
|
||||
|
||||
frame_widget.grid(row=side_menu_row, column=0, pady=(0,1), sticky="ew")
|
||||
frame_widget.grid_columnconfigure(0, weight=1)
|
||||
|
||||
label_widget = CTkLabel(
|
||||
frame_widget,
|
||||
text=text,
|
||||
height=0,
|
||||
corner_radius=0,
|
||||
font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.SIDE_MENU_LABELS_FONT_SIZE, weight="normal"),
|
||||
anchor="w",
|
||||
text_color=settings.ctm.LABELS_TEXT_COLOR,
|
||||
)
|
||||
setattr(config_window, label_attr_name, label_widget)
|
||||
|
||||
selected_mark_widget = CTkFrame(frame_widget, corner_radius=0, fg_color=settings.ctm.SIDE_MENU_SELECTED_MARK_ACTIVE_BG_COLOR, width=3, height=0)
|
||||
setattr(config_window, selected_mark_attr_name, selected_mark_widget)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Arrange
|
||||
selected_mark_widget.place(relx=-1, rely=0.5, relheight=1, anchor="w")
|
||||
label_widget.grid(row=0, column=0, padx=settings.uism.SIDE_MENU_LABELS_IPADX, pady=settings.uism.SIDE_MENU_LABELS_IPADY, sticky="ew")
|
||||
|
||||
bindEnterAndLeaveColor([frame_widget, label_widget], settings.ctm.SIDE_MENU_LABELS_HOVERED_BG_COLOR, settings.ctm.SIDE_MENU_LABELS_BG_COLOR)
|
||||
bindButtonPressColor([frame_widget, label_widget], settings.ctm.SIDE_MENU_LABELS_CLICKED_BG_COLOR, settings.ctm.SIDE_MENU_LABELS_BG_COLOR)
|
||||
|
||||
frame_widget.passive_function = command
|
||||
bindButtonReleaseFunction([frame_widget, label_widget], command)
|
||||
@@ -0,0 +1,61 @@
|
||||
from customtkinter import CTkFont, CTkFrame, CTkLabel
|
||||
|
||||
|
||||
def createSettingBoxContainer(config_window, settings, setting_box_container_settings):
|
||||
|
||||
|
||||
def createSectionTitle(container_widget, section_title):
|
||||
setting_box_wrapper_section_title_frame = CTkFrame(container_widget, corner_radius=0, fg_color=settings.ctm.MAIN_BG_COLOR, width=0, height=0)
|
||||
|
||||
setting_box_wrapper_section_title = CTkLabel(
|
||||
setting_box_wrapper_section_title_frame,
|
||||
text=section_title,
|
||||
anchor="w",
|
||||
height=0,
|
||||
font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.SB__SECTION_TITLE_FONT_SIZE, weight="normal"),
|
||||
text_color=settings.ctm.LABELS_TEXT_COLOR
|
||||
)
|
||||
setting_box_wrapper_section_title.grid(row=0, column=0, padx=0, pady=settings.uism.SB__SECTION_TITLE_BOTTOM_PADY)
|
||||
|
||||
return setting_box_wrapper_section_title_frame
|
||||
|
||||
# Common setting
|
||||
|
||||
# Setting box container
|
||||
setting_box_container_widget = CTkFrame(config_window.main_setting_box_bg_wrapper, corner_radius=0, fg_color=settings.ctm.MAIN_BG_COLOR, width=0, height=0)
|
||||
setattr(config_window, setting_box_container_settings["setting_box_container_attr_name"], setting_box_container_widget)
|
||||
|
||||
|
||||
|
||||
|
||||
setting_boxes_length = len(setting_box_container_settings["setting_boxes"])
|
||||
setting_box_row = 0
|
||||
for i, setting_box_setting in enumerate(setting_box_container_settings["setting_boxes"]):
|
||||
SB__TOP_PADY = 0
|
||||
SB__BOTTOM_PADY = settings.uism.SB__BOTTOM_PADY
|
||||
|
||||
setting_box_and_section_title_wrapper = CTkFrame(setting_box_container_widget, fg_color=settings.ctm.SB__WRAPPER_BG_COLOR, corner_radius=0, width=0, height=0)
|
||||
|
||||
if setting_box_setting["section_title"] is not None:
|
||||
setting_box_wrapper_section_title_frame= createSectionTitle(
|
||||
container_widget=setting_box_and_section_title_wrapper,
|
||||
section_title=setting_box_setting["section_title"],
|
||||
)
|
||||
setting_box_wrapper_section_title_frame.grid(row=0, column=0, sticky="ew", padx=0, pady=0)
|
||||
if i == 0: SB__TOP_PADY = settings.uism.SB__TOP_PADY_IF_WITH_SECTION_TITLE
|
||||
|
||||
# if the first one of setting boxes, adjust top pady
|
||||
if i == 0: SB__TOP_PADY = settings.uism.SB__TOP_PADY_IF_WITHOUT_SECTION_TITLE
|
||||
|
||||
# if the last one of setting boxes, remove bottom pady
|
||||
if i+1 == setting_boxes_length: SB__BOTTOM_PADY = 0
|
||||
|
||||
setting_box_wrapper = CTkFrame(setting_box_and_section_title_wrapper, fg_color=settings.ctm.SB__WRAPPER_BG_COLOR, corner_radius=0, width=0, height=0)
|
||||
setting_box_wrapper.grid(row=1, column=0)
|
||||
setting_box_row+=1
|
||||
|
||||
setting_box_and_section_title_wrapper.grid(row=setting_box_row, column=0, sticky="ew", padx=0, pady=(SB__TOP_PADY, SB__BOTTOM_PADY))
|
||||
|
||||
if setting_box_setting["setting_box"] is not None:
|
||||
setting_box_setting["setting_box"](setting_box_wrapper=setting_box_wrapper, config_window=config_window, settings=settings)
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
from customtkinter import CTkFrame, CTkScrollableFrame
|
||||
|
||||
from ....ui_utils import setDefaultActiveTab
|
||||
|
||||
from .addConfigSideMenuItem import addConfigSideMenuItem
|
||||
from .createSettingBoxContainer import createSettingBoxContainer
|
||||
|
||||
|
||||
from .setting_box_containers import createSettingBox_General
|
||||
|
||||
|
||||
def createSideMenuAndSettingsBoxContainers(config_window, settings):
|
||||
|
||||
# Main container
|
||||
config_window.main_bg_container = CTkFrame(config_window, corner_radius=0, fg_color=settings.ctm.MAIN_BG_COLOR, width=0, height=0)
|
||||
config_window.main_bg_container.grid(row=1, column=1, sticky="nsew")
|
||||
|
||||
config_window.main_bg_container.grid_columnconfigure(0, weight=1)
|
||||
config_window.main_bg_container.grid_rowconfigure(0, weight=0)
|
||||
|
||||
|
||||
|
||||
|
||||
# Side menu Base
|
||||
config_window.grid_rowconfigure(1, weight=1)
|
||||
config_window.side_menu_bg_container = CTkFrame(config_window, corner_radius=0, fg_color=settings.ctm.SIDE_MENU_BG_COLOR, width=0, height=0)
|
||||
config_window.side_menu_bg_container.grid(row=1, column=0, sticky="nsew")
|
||||
|
||||
|
||||
config_window.side_menu_container = CTkFrame(config_window.side_menu_bg_container, corner_radius=0, fg_color=settings.ctm.SIDE_MENU_LABELS_BG_FOR_FAKE_BORDER_COLOR, width=0, height=0)
|
||||
config_window.side_menu_container.grid(row=0, column=0, padx=settings.uism.TOP_BAR_SIDE__TITLE_PADX, pady=(settings.uism.SIDE_MENU_TOP_PADY, 0))
|
||||
|
||||
|
||||
|
||||
# Setting box container
|
||||
config_window.main_bg_container.grid_rowconfigure(1, weight=1)
|
||||
config_window.main_setting_box_scrollable_container = CTkScrollableFrame(config_window.main_bg_container, corner_radius=0, fg_color=settings.ctm.MAIN_BG_COLOR)
|
||||
config_window.main_setting_box_scrollable_container.grid(row=1, column=0, sticky="nsew")
|
||||
|
||||
|
||||
config_window.main_setting_box_bg_wrapper = CTkFrame(config_window.main_setting_box_scrollable_container, corner_radius=0, width=0, height=0, fg_color=settings.ctm.MAIN_BG_COLOR)
|
||||
config_window.main_setting_box_bg_wrapper.grid(row=0, column=0, pady=settings.uism.SB__BOTTOM_MARGIN, sticky="n")
|
||||
|
||||
|
||||
|
||||
side_menu_and_setting_box_containers_settings = [
|
||||
{
|
||||
"side_menu_tab_attr_name": "side_menu_tab_general",
|
||||
"label_attr_name": "label_general",
|
||||
"selected_mark_attr_name": "translation_selected_mark",
|
||||
"text": "General",
|
||||
"setting_box_container_settings": {
|
||||
"setting_box_container_attr_name": "setting_box_container_general",
|
||||
"setting_boxes": [
|
||||
{ "section_title": None, "setting_box": createSettingBox_General },
|
||||
# { "section_title": "General Section Title", "setting_box": createSettingBox_General },
|
||||
# { "section_title": None, "setting_box": createSettingBox_General },
|
||||
]
|
||||
},
|
||||
"activate_by_default": True,
|
||||
},
|
||||
{
|
||||
"side_menu_tab_attr_name": "side_menu_tab_translation",
|
||||
"label_attr_name": "label_translation",
|
||||
"selected_mark_attr_name": "transcription_send_selected_mark",
|
||||
"text": "Translation",
|
||||
"setting_box_container_settings": {
|
||||
"setting_box_container_attr_name": "setting_box_container_translation",
|
||||
"setting_boxes": [
|
||||
{ "section_title": None, "setting_box": None },
|
||||
]
|
||||
},
|
||||
},
|
||||
{
|
||||
"side_menu_tab_attr_name": "side_menu_tab_transcription",
|
||||
"label_attr_name": "label_transcription",
|
||||
"selected_mark_attr_name": "transcription_receive_selected_mark",
|
||||
"text": "Transcription",
|
||||
"setting_box_container_settings": {
|
||||
"setting_box_container_attr_name": "setting_box_container_transcription",
|
||||
"setting_boxes": [
|
||||
{ "section_title": None, "setting_box": None },
|
||||
]
|
||||
},
|
||||
},
|
||||
{
|
||||
"side_menu_tab_attr_name": "side_menu_tab_parameters",
|
||||
"label_attr_name": "label_parameters",
|
||||
"selected_mark_attr_name": "foreground_selected_mark",
|
||||
"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",
|
||||
"label_attr_name": "label_others",
|
||||
"selected_mark_attr_name": "foreground_selected_mark",
|
||||
"text": "Others",
|
||||
"setting_box_container_settings": {
|
||||
"setting_box_container_attr_name": "setting_box_container_others",
|
||||
"setting_boxes": [
|
||||
{ "section_title": None, "setting_box": None },
|
||||
]
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
all_side_menu_tab_attr_name = [item["side_menu_tab_attr_name"] for item in side_menu_and_setting_box_containers_settings]
|
||||
|
||||
side_menu_row=0
|
||||
for sm_and_sbc_setting in side_menu_and_setting_box_containers_settings:
|
||||
addConfigSideMenuItem(
|
||||
config_window=config_window,
|
||||
settings=settings,
|
||||
side_menu_settings=sm_and_sbc_setting,
|
||||
side_menu_row=side_menu_row,
|
||||
all_side_menu_tab_attr_name=all_side_menu_tab_attr_name,
|
||||
)
|
||||
side_menu_row+=1
|
||||
|
||||
|
||||
createSettingBoxContainer(
|
||||
config_window=config_window,
|
||||
settings=settings,
|
||||
setting_box_container_settings=sm_and_sbc_setting["setting_box_container_settings"],
|
||||
|
||||
)
|
||||
|
||||
|
||||
if sm_and_sbc_setting.get("activate_by_default", None) is not None:
|
||||
# Set default active side menu tab
|
||||
config_window.main_current_active_config_title.configure(text=sm_and_sbc_setting["text"])
|
||||
config_window.current_active_side_menu_tab = getattr(config_window, sm_and_sbc_setting["side_menu_tab_attr_name"])
|
||||
setDefaultActiveTab(
|
||||
active_tab_widget=config_window.current_active_side_menu_tab,
|
||||
active_bg_color=settings.ctm.SIDE_MENU_LABELS_BG_COLOR,
|
||||
active_text_color=settings.ctm.SIDE_MENU_LABELS_SELECTED_TEXT_COLOR
|
||||
)
|
||||
config_window.current_active_side_menu_tab.children["!ctkframe"].place(relx=0)
|
||||
|
||||
# Set default active setting box container
|
||||
config_window.current_active_setting_box_container = getattr(config_window, sm_and_sbc_setting["setting_box_container_settings"]["setting_box_container_attr_name"])
|
||||
config_window.current_active_setting_box_container.grid()
|
||||
|
||||
|
||||
@@ -0,0 +1,494 @@
|
||||
from customtkinter import CTkOptionMenu, CTkFont, CTkFrame, CTkLabel, CTkRadioButton, CTkEntry, CTkSlider, CTkSwitch, CTkCheckBox, CTkProgressBar, END as CTK_END
|
||||
from ctk_scrollable_dropdown import CTkScrollableDropdown
|
||||
|
||||
from vrct_gui.ui_utils import createButtonWithImage
|
||||
|
||||
|
||||
|
||||
class SettingBoxGenerator():
|
||||
def __init__(self, config_window, settings):
|
||||
|
||||
self.IS_CONFIG_WINDOW_COMPACT_MODE = settings.IS_CONFIG_WINDOW_COMPACT_MODE
|
||||
self.ctm = settings.ctm
|
||||
self.uism = settings.uism
|
||||
self.FONT_FAMILY = settings.FONT_FAMILY
|
||||
self.config_window = config_window
|
||||
|
||||
|
||||
|
||||
def _createSettingBoxFrameWrapper(self, setting_box_frame):
|
||||
setting_box_frame_wrapper = CTkFrame(setting_box_frame, corner_radius=0, fg_color=self.ctm.SB__BG_COLOR, width=self.uism.SB__MAIN_WIDTH, height=0)
|
||||
setting_box_frame_wrapper.grid(row=0, column=0, padx=self.uism.SB__IPADX, pady=self.uism.SB__IPADY, sticky="ew")
|
||||
setting_box_frame_wrapper.grid_columnconfigure((0,1), weight=1, minsize=int(self.uism.SB__MAIN_WIDTH / 2))
|
||||
return setting_box_frame_wrapper
|
||||
|
||||
def _createSettingBoxFrame(self, parent_widget, label_text, desc_text):
|
||||
setting_box_frame = CTkFrame(parent_widget, corner_radius=0, fg_color=self.ctm.SB__BG_COLOR, width=0, height=0)
|
||||
setting_box_frame_wrapper = self._createSettingBoxFrameWrapper(setting_box_frame)
|
||||
self._setSettingBoxLabels(setting_box_frame_wrapper, label_text, desc_text)
|
||||
|
||||
# "pady=(0,1)" is for bottom padding. It can be removed(override) when you do like "self.attr_name.grid(row=row, pady=0)"
|
||||
setting_box_frame.grid(column=0, padx=0, pady=(0,1), sticky="ew")
|
||||
return (setting_box_frame, setting_box_frame_wrapper)
|
||||
|
||||
def _setSettingBoxLabels(self, setting_box_frame, label_text, desc_text=False):
|
||||
|
||||
setting_box_labels_frame = CTkFrame(setting_box_frame, corner_radius=0, fg_color=self.ctm.SB__BG_COLOR, width=0, height=0)
|
||||
|
||||
setting_box_label = CTkLabel(
|
||||
setting_box_labels_frame,
|
||||
text=label_text,
|
||||
anchor="w",
|
||||
# height=0,
|
||||
font=CTkFont(family=self.FONT_FAMILY, size=self.uism.SB__LABEL_FONT_SIZE, weight="normal"),
|
||||
text_color=self.ctm.LABELS_TEXT_COLOR
|
||||
)
|
||||
setting_box_label.grid(row=0, column=0, padx=0, pady=0, sticky="ew")
|
||||
|
||||
if desc_text == False or self.IS_CONFIG_WINDOW_COMPACT_MODE is True:
|
||||
pass
|
||||
else:
|
||||
self.setting_box_desc = CTkLabel(
|
||||
setting_box_labels_frame,
|
||||
text=desc_text,
|
||||
anchor="w",
|
||||
justify="left",
|
||||
# height=0,
|
||||
wraplength=int(self.uism.SB__MAIN_WIDTH / 2),
|
||||
font=CTkFont(family=self.FONT_FAMILY, size=self.uism.SB__DESC_FONT_SIZE, weight="normal"),
|
||||
text_color=self.ctm.LABELS_DESC_TEXT_COLOR
|
||||
)
|
||||
self.setting_box_desc.grid(row=1, column=0, padx=0, pady=(self.uism.SB__DESC_TOP_PADY,0), sticky="ew")
|
||||
|
||||
setting_box_labels_frame.grid(row=0, column=0, padx=0, pady=0, sticky="w")
|
||||
|
||||
|
||||
|
||||
def createSettingBoxDropdownMenu(self, parent_widget, label_text, desc_text, optionmenu_attr_name, dropdown_menu_attr_name, dropdown_menu_values, command, variable):
|
||||
(setting_box_frame, setting_box_frame_wrapper) = self._createSettingBoxFrame(parent_widget, label_text, desc_text)
|
||||
|
||||
setting_box_dropdown_menu_frame = CTkFrame(setting_box_frame_wrapper, corner_radius=0, width=0, height=0, fg_color=self.ctm.SB__BG_COLOR)
|
||||
setting_box_dropdown_menu_frame.grid(row=0, column=1, padx=0, sticky="e")
|
||||
|
||||
self.createOption_DropdownMenu(
|
||||
setting_box_dropdown_menu_frame=setting_box_dropdown_menu_frame,
|
||||
optionmenu_attr_name=optionmenu_attr_name,
|
||||
dropdown_menu_attr_name=dropdown_menu_attr_name,
|
||||
dropdown_menu_values=dropdown_menu_values,
|
||||
command=command,
|
||||
variable=variable,
|
||||
)
|
||||
|
||||
return setting_box_frame
|
||||
|
||||
|
||||
|
||||
|
||||
def createSettingBoxSwitch(self, parent_widget, label_text, desc_text, switch_attr_name, is_checked, command):
|
||||
(setting_box_frame, setting_box_frame_wrapper) = self._createSettingBoxFrame(parent_widget, label_text, desc_text)
|
||||
|
||||
setting_box_switch_frame = CTkFrame(setting_box_frame_wrapper, corner_radius=0, width=0, height=0, fg_color=self.ctm.SB__BG_COLOR)
|
||||
setting_box_switch_frame.grid(row=0, column=1, padx=0, sticky="e")
|
||||
|
||||
switch_widget = CTkSwitch(
|
||||
setting_box_switch_frame,
|
||||
text=None,
|
||||
height=0,
|
||||
width=0,
|
||||
corner_radius=int(self.uism.SB__SWITCH_BOX_HEIGHT/2),
|
||||
border_width=0,
|
||||
switch_height=self.uism.SB__SWITCH_BOX_HEIGHT,
|
||||
switch_width=self.uism.SB__SWITCH_BOX_WIDTH,
|
||||
onvalue=True,
|
||||
offvalue=False,
|
||||
command=command,
|
||||
fg_color=self.ctm.SB__SWITCH_BOX_BG_COLOR,
|
||||
# bg_color="red",
|
||||
progress_color=self.ctm.SB__SWITCH_BOX_ACTIVE_BG_COLOR,
|
||||
)
|
||||
setattr(self.config_window, switch_attr_name, switch_widget)
|
||||
|
||||
switch_widget.select() if is_checked else switch_widget.deselect()
|
||||
|
||||
switch_widget.grid(row=0, column=0)
|
||||
|
||||
return setting_box_frame
|
||||
|
||||
|
||||
|
||||
def createSettingBoxCheckbox(self, parent_widget, label_text, desc_text, checkbox_attr_name, is_checked, command):
|
||||
(setting_box_frame, setting_box_frame_wrapper) = self._createSettingBoxFrame(parent_widget, label_text, desc_text)
|
||||
|
||||
setting_box_checkbox_frame = CTkFrame(setting_box_frame_wrapper, corner_radius=0, width=0, height=0, fg_color=self.ctm.SB__BG_COLOR)
|
||||
setting_box_checkbox_frame.grid(row=0, column=1, padx=0, sticky="e")
|
||||
|
||||
checkbox_widget = CTkCheckBox(
|
||||
setting_box_checkbox_frame,
|
||||
text=None,
|
||||
width=0,
|
||||
checkbox_width=self.uism.SB__CHECKBOX_SIZE,
|
||||
checkbox_height=self.uism.SB__CHECKBOX_SIZE,
|
||||
onvalue=True,
|
||||
offvalue=False,
|
||||
command=command,
|
||||
corner_radius=self.uism.SB__CHECKBOX_CORNER_RADIUS,
|
||||
border_width=self.uism.SB__CHECKBOX_BORDER_WIDTH,
|
||||
border_color=self.ctm.SB__CHECKBOX_BORDER_COLOR,
|
||||
hover_color=self.ctm.SB__CHECKBOX_HOVER_COLOR,
|
||||
checkmark_color=self.ctm.SB__CHECKBOX_CHECKMARK_COLOR,
|
||||
fg_color=self.ctm.SB__CHECKBOX_CHECKED_COLOR,
|
||||
# fg_color=self.ctm.SB__SWITCH_BOX_BG_COLOR,
|
||||
# bg_color="red",
|
||||
# progress_color=self.ctm.SB__SWITCH_BOX_ACTIVE_BG_COLOR,
|
||||
)
|
||||
setattr(self.config_window, checkbox_attr_name, checkbox_widget)
|
||||
|
||||
checkbox_widget.select() if is_checked else checkbox_widget.deselect()
|
||||
|
||||
checkbox_widget.grid(row=0, column=0)
|
||||
|
||||
return setting_box_frame
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def createSettingBoxSlider(self, parent_widget, label_text, desc_text, slider_attr_name, slider_range, slider_number_of_steps, command, variable):
|
||||
(setting_box_frame, setting_box_frame_wrapper) = self._createSettingBoxFrame(parent_widget, label_text, desc_text)
|
||||
|
||||
setting_box_slider_frame = CTkFrame(setting_box_frame_wrapper, corner_radius=0, width=0, height=0, fg_color=self.ctm.SB__BG_COLOR)
|
||||
setting_box_slider_frame.grid(row=0, column=1, padx=0, sticky="e")
|
||||
|
||||
slider_widget = CTkSlider(
|
||||
setting_box_slider_frame,
|
||||
from_=slider_range[0],
|
||||
to=slider_range[1],
|
||||
number_of_steps=slider_number_of_steps,
|
||||
button_color=self.ctm.SB__SLIDER_BUTTON_COLOR,
|
||||
button_hover_color=self.ctm.SB__SLIDER_BUTTON_HOVERED_COLOR,
|
||||
command=command,
|
||||
variable=variable,
|
||||
)
|
||||
setattr(self.config_window, slider_attr_name, slider_widget)
|
||||
|
||||
slider_widget.grid(row=0, column=0)
|
||||
|
||||
return setting_box_frame
|
||||
|
||||
|
||||
|
||||
|
||||
def createSettingBoxProgressbarXSlider(self,
|
||||
parent_widget, label_text, desc_text, command,
|
||||
entry_attr_name,
|
||||
slider_attr_name, slider_range, slider_number_of_steps,
|
||||
progressbar_attr_name,
|
||||
passive_button_attr_name, passive_button_command,
|
||||
active_button_attr_name, active_button_command,
|
||||
button_image_filename,
|
||||
variable,
|
||||
):
|
||||
|
||||
|
||||
(setting_box_frame, setting_box_frame_wrapper) = self._createSettingBoxFrame(parent_widget, label_text, desc_text)
|
||||
|
||||
setting_box_progressbar_x_slider_frame = CTkFrame(setting_box_frame_wrapper, corner_radius=0, width=0, height=0, fg_color=self.ctm.SB__BG_COLOR)
|
||||
setting_box_progressbar_x_slider_frame.grid(row=0, column=1, padx=0, sticky="e")
|
||||
|
||||
|
||||
ENTRY_WIDTH = self.uism.SB__PROGRESSBAR_X_SLIDER__ENTRY_WIDTH
|
||||
BAR_WIDTH = self.uism.SB__PROGRESSBAR_X_SLIDER__BAR_WIDTH
|
||||
|
||||
BAR_PADDING = int(ENTRY_WIDTH + self.uism.SB__PROGRESSBAR_X_SLIDER__BAR_RIGHT_PADX)
|
||||
BUTTON_PADDING = int(BAR_WIDTH + BAR_PADDING + self.uism.SB__PROGRESSBAR_X_SLIDER__BUTTON_RIGHT_PADX)
|
||||
|
||||
def adjusted_command__for_entry_bind__Any_KeyRelease(e):
|
||||
# try:
|
||||
# int(e.widget.get())
|
||||
# except:
|
||||
# e.widget.delete(0, CTK_END)
|
||||
# return
|
||||
# print(int(e.widget.get()))
|
||||
|
||||
|
||||
i = int(e.widget.get())
|
||||
if i < 0 or i > slider_range[1]:
|
||||
e.widget.delete(0, CTK_END)
|
||||
i = max(0, min(int(e.widget.get()), slider_range[1]))
|
||||
# e.widget.insert(0, i)
|
||||
command(i)
|
||||
def adjusted_command__for_slider(value):
|
||||
command(int(value))
|
||||
|
||||
entry_widget = CTkEntry(
|
||||
setting_box_progressbar_x_slider_frame,
|
||||
width=ENTRY_WIDTH,
|
||||
height=self.uism.SB__PROGRESSBAR_X_SLIDER__ENTRY_HEIGHT,
|
||||
textvariable=variable,
|
||||
font=CTkFont(family=self.FONT_FAMILY, size=self.uism.SB__ENTRY_FONT_SIZE, weight="normal"),
|
||||
)
|
||||
|
||||
entry_widget.bind("<Any-KeyRelease>", adjusted_command__for_entry_bind__Any_KeyRelease)
|
||||
entry_widget.grid(row=0, column=0, padx=0, pady=0, sticky="e")
|
||||
setattr(self.config_window, entry_attr_name, entry_widget)
|
||||
|
||||
|
||||
# at least 2px is needed otherwise the slider button is gonna broken.
|
||||
SLIDER_BORDER_WIDTH = max(2,self.uism.SB__PROGRESSBAR_X_SLIDER__SLIDER_BUTTON_LENGTH)
|
||||
SLIDER_BUTTON_LENGTH = int(SLIDER_BORDER_WIDTH/2)
|
||||
slider_widget = CTkSlider(
|
||||
setting_box_progressbar_x_slider_frame,
|
||||
from_=slider_range[0],
|
||||
to=slider_range[1],
|
||||
number_of_steps=slider_number_of_steps,
|
||||
command=adjusted_command__for_slider,
|
||||
variable=variable,
|
||||
height=self.uism.SB__PROGRESSBAR_X_SLIDER__SLIDER_HEIGHT,
|
||||
width=BAR_WIDTH,
|
||||
border_width=0,
|
||||
button_length=SLIDER_BORDER_WIDTH,
|
||||
button_corner_radius=SLIDER_BUTTON_LENGTH,
|
||||
corner_radius=0,
|
||||
button_color=self.ctm.SB__PROGRESSBAR_X_SLIDER__SLIDER_BUTTON_COLOR,
|
||||
button_hover_color=self.ctm.SB__PROGRESSBAR_X_SLIDER__SLIDER_BUTTON_HOVERED_COLOR,
|
||||
fg_color=self.ctm.SB__BG_COLOR,
|
||||
progress_color=self.ctm.SB__BG_COLOR,
|
||||
border_color=self.ctm.SB__BG_COLOR,
|
||||
)
|
||||
slider_widget.grid(row=0, column=0, padx=(0, BAR_PADDING), sticky="e")
|
||||
setattr(self.config_window, slider_attr_name, slider_widget)
|
||||
|
||||
|
||||
|
||||
|
||||
progressbar_widget = CTkProgressBar(
|
||||
setting_box_progressbar_x_slider_frame,
|
||||
width=BAR_WIDTH,
|
||||
height=self.uism.SB__PROGRESSBAR_X_SLIDER__PROGRESSBAR_HEIGHT,
|
||||
corner_radius=0,
|
||||
)
|
||||
setattr(self.config_window, progressbar_attr_name, progressbar_widget)
|
||||
progressbar_widget.grid(row=0, column=0, padx=(0, BAR_PADDING), sticky="e")
|
||||
progressbar_widget.set(0)
|
||||
|
||||
|
||||
|
||||
|
||||
passive_button_wrapper = self._createPassiveButtonForProgressbarXSlider(setting_box_progressbar_x_slider_frame, BUTTON_PADDING, passive_button_command, button_image_filename)
|
||||
setattr(self.config_window, passive_button_attr_name, passive_button_wrapper)
|
||||
|
||||
active_button_wrapper = self._createActiveButtonForProgressbarXSlider(setting_box_progressbar_x_slider_frame, BUTTON_PADDING, active_button_command, button_image_filename)
|
||||
setattr(self.config_window, active_button_attr_name, active_button_wrapper)
|
||||
|
||||
passive_button_wrapper.grid()
|
||||
return setting_box_frame
|
||||
|
||||
|
||||
|
||||
|
||||
def createSettingBoxEntry(self, parent_widget, label_text, desc_text, entry_attr_name, entry_width, entry_bind__Any_KeyRelease, entry_textvariable):
|
||||
(setting_box_frame, setting_box_frame_wrapper) = self._createSettingBoxFrame(parent_widget, label_text, desc_text)
|
||||
|
||||
setting_box_entry_frame = CTkFrame(setting_box_frame_wrapper, corner_radius=0, width=0, height=0, fg_color=self.ctm.SB__BG_COLOR)
|
||||
setting_box_entry_frame.grid(row=0, column=1, padx=0, sticky="e")
|
||||
|
||||
entry_widget = CTkEntry(
|
||||
setting_box_entry_frame,
|
||||
width=entry_width,
|
||||
height=self.uism.SB__PROGRESSBAR_X_SLIDER__ENTRY_HEIGHT,
|
||||
textvariable=entry_textvariable,
|
||||
font=CTkFont(family=self.FONT_FAMILY, size=self.uism.SB__ENTRY_FONT_SIZE, weight="normal"),
|
||||
)
|
||||
entry_widget.bind("<Any-KeyRelease>", entry_bind__Any_KeyRelease)
|
||||
setattr(self.config_window, entry_attr_name, entry_widget)
|
||||
|
||||
|
||||
entry_widget.grid(row=0, column=0)
|
||||
|
||||
return setting_box_frame
|
||||
|
||||
|
||||
|
||||
# if setting_box_type == "dropdown_menu_x_dropdown_menu":
|
||||
# self.setting_box_dropdown_menu_x_dropdown_menu = CTkFrame(self.setting_box, corner_radius=0, fg_color=self.ctm.SB__BG_COLOR, width=0, height=0)
|
||||
# self.setting_box_dropdown_menu_x_dropdown_menu.grid(row=0, column=1, padx=(0, self.uism.SB__RIGHT_PADX), rowspan=2, sticky="e")
|
||||
|
||||
|
||||
|
||||
# # Labels
|
||||
# self.optionmenu_label_left = CTkLabel(
|
||||
# self.setting_box_dropdown_menu_x_dropdown_menu,
|
||||
# text=kwargs["left_dropdown_menu_label"],
|
||||
# font=CTkFont(family=self.FONT_FAMILY, size=self.uism.SB__OPTION_MENU_FONT_SIZE, weight="normal"),
|
||||
# )
|
||||
# self.optionmenu_label_left.grid(row=0, column=0)
|
||||
|
||||
# self.the_space_between_optionmenu = CTkLabel(
|
||||
# self.setting_box_dropdown_menu_x_dropdown_menu,
|
||||
# text=None,
|
||||
# )
|
||||
# self.the_space_between_optionmenu.grid(row=0, column=1)
|
||||
|
||||
|
||||
# self.optionmenu_label_right = CTkLabel(
|
||||
# self.setting_box_dropdown_menu_x_dropdown_menu,
|
||||
# text=kwargs["right_dropdown_menu_label"],
|
||||
# font=CTkFont(family=self.FONT_FAMILY, size=self.uism.SB__OPTION_MENU_FONT_SIZE, weight="normal"),
|
||||
# )
|
||||
# self.optionmenu_label_right.grid(row=0, column=2)
|
||||
|
||||
|
||||
|
||||
# # Option menus
|
||||
# self.createOption_DropdownMenu(
|
||||
# setattr_obj,
|
||||
# self.setting_box_dropdown_menu_x_dropdown_menu,
|
||||
# kwargs["left_optionmenu_attr_name"],
|
||||
# kwargs["left_dropdown_menu_attr_name"],
|
||||
# dropdown_menu_values=kwargs["left_dropdown_menu_values"],
|
||||
# width=150,
|
||||
# command=kwargs["left_dropdown_menu_command"],
|
||||
# variable=kwargs["left_dropdown_menu_variable"],
|
||||
# )
|
||||
# getattr(setattr_obj, kwargs["left_optionmenu_attr_name"]).grid(row=1, column=0)
|
||||
|
||||
|
||||
|
||||
# self.the_label_between_optionmenu = CTkLabel(
|
||||
# self.setting_box_dropdown_menu_x_dropdown_menu,
|
||||
# text="-->",
|
||||
# # anchor="w",
|
||||
# font=CTkFont(family=self.FONT_FAMILY, size=self.uism.SB__OPTION_MENU_FONT_SIZE, weight="normal"),
|
||||
# text_color=self.ctm.LABELS_TEXT_COLOR
|
||||
# )
|
||||
# self.the_label_between_optionmenu.grid(row=1, column=1, padx=self.uism.SB__RIGHT_PADX/2)
|
||||
|
||||
|
||||
# self.createOption_DropdownMenu(
|
||||
# setattr_obj,
|
||||
# self.setting_box_dropdown_menu_x_dropdown_menu,
|
||||
# kwargs["right_optionmenu_attr_name"],
|
||||
# kwargs["right_dropdown_menu_attr_name"],
|
||||
# dropdown_menu_values=kwargs["right_dropdown_menu_values"],
|
||||
# width=150,
|
||||
# command=kwargs["right_dropdown_menu_command"],
|
||||
# variable=kwargs["right_dropdown_menu_variable"],
|
||||
# )
|
||||
# getattr(setattr_obj, kwargs["right_optionmenu_attr_name"]).grid(row=1, column=2)
|
||||
|
||||
|
||||
|
||||
|
||||
# if setting_box_type == "radio_buttons":
|
||||
# self.setting_box_radio_buttons_frame = CTkFrame(self.setting_box, corner_radius=0, width=0, height=0)
|
||||
# self.setting_box_radio_buttons_frame.grid(row=0, column=1, padx=(0, self.uism.SB__RIGHT_PADX), rowspan=2, sticky="e")
|
||||
|
||||
# RADIO_BUTTON_RIGHT_PAD = 14
|
||||
# self.setting_box_radio_button_1 = CTkRadioButton(
|
||||
# self.setting_box_radio_buttons_frame,
|
||||
# text="lorem ipsum",
|
||||
# font=CTkFont(family=self.FONT_FAMILY, size=self.uism.SB__RADIO_BUTTON_FONT_SIZE, weight="normal")
|
||||
# )
|
||||
# self.setting_box_radio_button_1.grid(row=0, column=0, padx=(0,RADIO_BUTTON_RIGHT_PAD), sticky="e")
|
||||
|
||||
# self.setting_box_radio_button_2 = CTkRadioButton(
|
||||
# self.setting_box_radio_buttons_frame,
|
||||
# text="lorem ipsum",
|
||||
# font=CTkFont(family=self.FONT_FAMILY, size=self.uism.SB__RADIO_BUTTON_FONT_SIZE, weight="normal")
|
||||
# )
|
||||
# self.setting_box_radio_button_2.grid(row=0, column=1, padx=(0,RADIO_BUTTON_RIGHT_PAD), sticky="e")
|
||||
|
||||
# self.setting_box_radio_button_3 = CTkRadioButton(
|
||||
# self.setting_box_radio_buttons_frame,
|
||||
# text="lorem ipsum",
|
||||
# font=CTkFont(family=self.FONT_FAMILY, size=self.uism.SB__RADIO_BUTTON_FONT_SIZE, weight="normal")
|
||||
# )
|
||||
# self.setting_box_radio_button_3.grid(row=0, column=2, padx=(0,RADIO_BUTTON_RIGHT_PAD), sticky="e")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def createOption_DropdownMenu(self, setting_box_dropdown_menu_frame, optionmenu_attr_name, dropdown_menu_attr_name, dropdown_menu_values, command, variable):
|
||||
option_menu_widget = CTkOptionMenu(
|
||||
setting_box_dropdown_menu_frame,
|
||||
height=self.uism.SB__OPTIONMENU_HEIGHT,
|
||||
width=self.uism.SB__OPTIONMENU_WIDTH,
|
||||
button_color=self.ctm.SB__OPTIONMENU_BG_COLOR,
|
||||
button_hover_color=self.ctm.SB__OPTIONMENU_HOVERED_BG_COLOR,
|
||||
fg_color=self.ctm.SB__OPTIONMENU_BG_COLOR,
|
||||
font=CTkFont(family=self.FONT_FAMILY, size=self.uism.SB__OPTION_MENU_FONT_SIZE, weight="normal"),
|
||||
variable=variable,
|
||||
anchor="w",
|
||||
)
|
||||
option_menu_widget.grid(row=0, column=0, sticky="e")
|
||||
setattr(self.config_window, optionmenu_attr_name, option_menu_widget)
|
||||
|
||||
# set the value to the option menu's variable automatically
|
||||
def adjustedCommand(selected_value):
|
||||
option_menu_widget.set(selected_value)
|
||||
command(selected_value)
|
||||
|
||||
dropdown_menu_widget = CTkScrollableDropdown(
|
||||
option_menu_widget,
|
||||
values=dropdown_menu_values,
|
||||
justify="left",
|
||||
width=self.uism.SB__DROPDOWN_MENU_WIDTH,
|
||||
min_show_button_num=6,
|
||||
button_pady=0,
|
||||
frame_corner_radius=self.uism.SB__DROPDOWN_MENU_FRAME_CORNER_RADIUS,
|
||||
max_button_height=self.uism.SB__DROPDOWN_MENU_MAX_BUTTON_HEIGHT,
|
||||
max_height=self.uism.SB__DROPDOWN_MENU_FRAME_MAX_HEIGHT,
|
||||
font=CTkFont(family=self.FONT_FAMILY, size=self.uism.SB__OPTION_MENU_FONT_SIZE, weight="normal"),
|
||||
command=adjustedCommand,
|
||||
)
|
||||
|
||||
# dropdown_menu_widget.bind(
|
||||
# "<Leave>",
|
||||
# lambda e: dropdown_menu_widget._withdraw() if not str(e.widget).startswith(str(dropdown_menu_widget.frame._parent_frame)) else None,
|
||||
# )
|
||||
dropdown_menu_widget.bind(
|
||||
"<Enter>",
|
||||
lambda e: print(e),
|
||||
)
|
||||
|
||||
setattr(self.config_window, dropdown_menu_attr_name, dropdown_menu_widget)
|
||||
return option_menu_widget
|
||||
|
||||
|
||||
|
||||
|
||||
def _createPassiveButtonForProgressbarXSlider(self, setting_box_progressbar_x_slider_frame, BUTTON_PADDING, button_command, button_image_filename):
|
||||
button_wrapper = createButtonWithImage(
|
||||
parent_widget=setting_box_progressbar_x_slider_frame,
|
||||
button_fg_color=self.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_COLOR,
|
||||
button_enter_color=self.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_HOVERED_COLOR,
|
||||
button_clicked_color=self.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_CLICKED_COLOR,
|
||||
button_image_filename=button_image_filename,
|
||||
button_image_size=self.uism.SB__PROGRESSBAR_X_SLIDER__BUTTON_ICON_SIZE,
|
||||
button_ipadxy=self.uism.SB__PROGRESSBAR_X_SLIDER__BUTTON_IPADXY,
|
||||
button_command=button_command,
|
||||
shape="circle",
|
||||
)
|
||||
button_wrapper.grid(row=0, column=0, padx=(0,BUTTON_PADDING), sticky="e")
|
||||
button_wrapper.grid_remove()
|
||||
return button_wrapper
|
||||
|
||||
|
||||
|
||||
def _createActiveButtonForProgressbarXSlider(self, setting_box_progressbar_x_slider_frame, BUTTON_PADDING, button_command, button_image_filename):
|
||||
button_wrapper = createButtonWithImage(
|
||||
parent_widget=setting_box_progressbar_x_slider_frame,
|
||||
button_fg_color=self.ctm.SB__PROGRESSBAR_X_SLIDER__ACTIVE_BUTTON_COLOR,
|
||||
button_enter_color=self.ctm.SB__PROGRESSBAR_X_SLIDER__ACTIVE_BUTTON_HOVERED_COLOR,
|
||||
button_clicked_color=self.ctm.SB__PROGRESSBAR_X_SLIDER__ACTIVE_BUTTON_CLICKED_COLOR,
|
||||
button_image_filename=button_image_filename,
|
||||
button_image_size=self.uism.SB__PROGRESSBAR_X_SLIDER__BUTTON_ICON_SIZE,
|
||||
button_ipadxy=self.uism.SB__PROGRESSBAR_X_SLIDER__BUTTON_IPADXY,
|
||||
button_command=button_command,
|
||||
shape="circle",
|
||||
)
|
||||
button_wrapper.grid(row=0, column=0, padx=(0,BUTTON_PADDING), sticky="e")
|
||||
button_wrapper.grid_remove()
|
||||
return button_wrapper
|
||||
@@ -0,0 +1 @@
|
||||
from .setting_box_general import createSettingBox_General
|
||||
@@ -0,0 +1 @@
|
||||
from .createSettingBox_General import createSettingBox_General
|
||||
@@ -0,0 +1,225 @@
|
||||
from time import sleep
|
||||
|
||||
from customtkinter import StringVar, IntVar
|
||||
|
||||
|
||||
from ..SettingBoxGenerator import SettingBoxGenerator
|
||||
|
||||
from config import config
|
||||
|
||||
def createSettingBox_General(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
|
||||
Reference in New Issue
Block a user