Merge branch 'view' into UI_2.0
This commit is contained in:
21
main.py
21
main.py
@@ -270,9 +270,19 @@ def setProgressBarMicEnergy(energy):
|
|||||||
def callbackCheckMicThreshold(is_turned_on):
|
def callbackCheckMicThreshold(is_turned_on):
|
||||||
print("callbackCheckMicThreshold", is_turned_on)
|
print("callbackCheckMicThreshold", is_turned_on)
|
||||||
if is_turned_on is True:
|
if is_turned_on is True:
|
||||||
|
view.setConfigWindowCompactModeSwitchStatusToDisabled()
|
||||||
|
|
||||||
|
view.setConfigWindowThresholdCheckWidgetsStatusToDisabled()
|
||||||
model.startCheckMicEnergy(setProgressBarMicEnergy)
|
model.startCheckMicEnergy(setProgressBarMicEnergy)
|
||||||
|
view.replaceConfigWindowMicThresholdCheckButtonToActive()
|
||||||
|
view.setConfigWindowThresholdCheckWidgetsStatusToNormal()
|
||||||
else:
|
else:
|
||||||
|
view.setConfigWindowThresholdCheckWidgetsStatusToDisabled()
|
||||||
model.stopCheckMicEnergy()
|
model.stopCheckMicEnergy()
|
||||||
|
view.replaceConfigWindowMicThresholdCheckButtonToPassive()
|
||||||
|
view.setConfigWindowThresholdCheckWidgetsStatusToNormal()
|
||||||
|
|
||||||
|
view.setConfigWindowCompactModeSwitchStatusToNormal()
|
||||||
|
|
||||||
def callbackSetMicRecordTimeout(value):
|
def callbackSetMicRecordTimeout(value):
|
||||||
print("callbackSetMicRecordTimeout", int(value))
|
print("callbackSetMicRecordTimeout", int(value))
|
||||||
@@ -318,9 +328,20 @@ def setProgressBarSpeakerEnergy(energy):
|
|||||||
def callbackCheckSpeakerThreshold(is_turned_on):
|
def callbackCheckSpeakerThreshold(is_turned_on):
|
||||||
print("callbackCheckSpeakerThreshold", is_turned_on)
|
print("callbackCheckSpeakerThreshold", is_turned_on)
|
||||||
if is_turned_on is True:
|
if is_turned_on is True:
|
||||||
|
view.setConfigWindowCompactModeSwitchStatusToDisabled()
|
||||||
|
|
||||||
|
view.setConfigWindowThresholdCheckWidgetsStatusToDisabled()
|
||||||
model.startCheckSpeakerEnergy(setProgressBarSpeakerEnergy)
|
model.startCheckSpeakerEnergy(setProgressBarSpeakerEnergy)
|
||||||
|
view.replaceConfigWindowSpeakerThresholdCheckButtonToActive()
|
||||||
|
view.setConfigWindowThresholdCheckWidgetsStatusToNormal()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
view.setConfigWindowThresholdCheckWidgetsStatusToDisabled()
|
||||||
model.stopCheckSpeakerEnergy()
|
model.stopCheckSpeakerEnergy()
|
||||||
|
view.replaceConfigWindowSpeakerThresholdCheckButtonToPassive()
|
||||||
|
view.setConfigWindowThresholdCheckWidgetsStatusToNormal()
|
||||||
|
|
||||||
|
view.setConfigWindowCompactModeSwitchStatusToNormal()
|
||||||
|
|
||||||
def callbackSetSpeakerRecordTimeout(value):
|
def callbackSetSpeakerRecordTimeout(value):
|
||||||
print("callbackSetSpeakerRecordTimeout", int(value))
|
print("callbackSetSpeakerRecordTimeout", int(value))
|
||||||
|
|||||||
44
view.py
44
view.py
@@ -403,6 +403,50 @@ class View():
|
|||||||
|
|
||||||
|
|
||||||
# Config Window
|
# Config Window
|
||||||
|
def setConfigWindowCompactModeSwitchStatusToDisabled(self):
|
||||||
|
vrct_gui.config_window.setting_box_compact_mode_switch_box.configure(state="disabled")
|
||||||
|
|
||||||
|
def setConfigWindowCompactModeSwitchStatusToNormal(self):
|
||||||
|
vrct_gui.config_window.setting_box_compact_mode_switch_box.configure(state="normal")
|
||||||
|
|
||||||
|
def setConfigWindowThresholdCheckWidgetsStatusToDisabled(self):
|
||||||
|
vrct_gui.changeConfigWindowWidgetsStatus(
|
||||||
|
status="disabled",
|
||||||
|
target_names=[
|
||||||
|
"mic_energy_threshold_check_button",
|
||||||
|
"speaker_energy_threshold_check_button",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
def setConfigWindowThresholdCheckWidgetsStatusToNormal(self):
|
||||||
|
vrct_gui.changeConfigWindowWidgetsStatus(
|
||||||
|
status="normal",
|
||||||
|
target_names=[
|
||||||
|
"mic_energy_threshold_check_button",
|
||||||
|
"speaker_energy_threshold_check_button",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
def replaceConfigWindowMicThresholdCheckButtonToActive(self):
|
||||||
|
vrct_gui.config_window.sb__progressbar_x_slider__passive_button_mic_energy_threshold.grid_remove()
|
||||||
|
vrct_gui.config_window.sb__progressbar_x_slider__active_button_mic_energy_threshold.grid()
|
||||||
|
|
||||||
|
def replaceConfigWindowMicThresholdCheckButtonToPassive(self):
|
||||||
|
vrct_gui.config_window.sb__progressbar_x_slider__active_button_mic_energy_threshold.grid_remove()
|
||||||
|
vrct_gui.config_window.sb__progressbar_x_slider__passive_button_mic_energy_threshold.grid()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def replaceConfigWindowSpeakerThresholdCheckButtonToActive(self):
|
||||||
|
vrct_gui.config_window.sb__progressbar_x_slider__passive_button_speaker_energy_threshold.grid_remove()
|
||||||
|
vrct_gui.config_window.sb__progressbar_x_slider__active_button_speaker_energy_threshold.grid()
|
||||||
|
|
||||||
|
def replaceConfigWindowSpeakerThresholdCheckButtonToPassive(self):
|
||||||
|
vrct_gui.config_window.sb__progressbar_x_slider__active_button_speaker_energy_threshold.grid_remove()
|
||||||
|
vrct_gui.config_window.sb__progressbar_x_slider__passive_button_speaker_energy_threshold.grid()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def reloadConfigWindowSettingBoxContainer(self):
|
def reloadConfigWindowSettingBoxContainer(self):
|
||||||
vrct_gui.config_window.settings.IS_CONFIG_WINDOW_COMPACT_MODE = config.IS_CONFIG_WINDOW_COMPACT_MODE
|
vrct_gui.config_window.settings.IS_CONFIG_WINDOW_COMPACT_MODE = config.IS_CONFIG_WINDOW_COMPACT_MODE
|
||||||
vrct_gui.config_window.reloadConfigWindowSettingBoxContainer()
|
vrct_gui.config_window.reloadConfigWindowSettingBoxContainer()
|
||||||
|
|||||||
37
vrct_gui/_changeConfigWindowWidgetsStatus.py
Normal file
37
vrct_gui/_changeConfigWindowWidgetsStatus.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
from customtkinter import CTkImage
|
||||||
|
|
||||||
|
from .ui_utils import getImageFileFromUiUtils
|
||||||
|
|
||||||
|
|
||||||
|
def _changeConfigWindowWidgetsStatus(config_window, settings, view_variable, status, target_names):
|
||||||
|
if target_names == "All":
|
||||||
|
target_names = ["mic_energy_threshold_check_button", "speaker_energy_threshold_check_button"]
|
||||||
|
|
||||||
|
|
||||||
|
for target_name in target_names:
|
||||||
|
match target_name:
|
||||||
|
case "mic_energy_threshold_check_button":
|
||||||
|
if status == "disabled":
|
||||||
|
config_window.sb__progressbar_x_slider__passive_button_mic_energy_threshold.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR)
|
||||||
|
config_window.sb__progressbar_x_slider__passive_button_mic_energy_threshold.children["!ctklabel"].configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR)
|
||||||
|
|
||||||
|
elif status == "normal":
|
||||||
|
config_window.sb__progressbar_x_slider__passive_button_mic_energy_threshold.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_COLOR)
|
||||||
|
config_window.sb__progressbar_x_slider__passive_button_mic_energy_threshold.children["!ctklabel"].configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_COLOR)
|
||||||
|
|
||||||
|
case "speaker_energy_threshold_check_button":
|
||||||
|
if status == "disabled":
|
||||||
|
config_window.sb__progressbar_x_slider__passive_button_speaker_energy_threshold.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR)
|
||||||
|
config_window.sb__progressbar_x_slider__passive_button_speaker_energy_threshold.children["!ctklabel"].configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR)
|
||||||
|
|
||||||
|
elif status == "normal":
|
||||||
|
config_window.sb__progressbar_x_slider__passive_button_speaker_energy_threshold.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_COLOR)
|
||||||
|
config_window.sb__progressbar_x_slider__passive_button_speaker_energy_threshold.children["!ctklabel"].configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_COLOR)
|
||||||
|
|
||||||
|
|
||||||
|
case _:
|
||||||
|
raise ValueError(f"No matching case for target_name: {target_name}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
config_window.update()
|
||||||
@@ -10,27 +10,9 @@ def createSettingBox_Mic(setting_box_wrapper, config_window, settings, view_vari
|
|||||||
createSettingBoxEntry = sbg.createSettingBoxEntry
|
createSettingBoxEntry = sbg.createSettingBoxEntry
|
||||||
|
|
||||||
|
|
||||||
def checkbox_input_mic_threshold_check_callback(e, passive_button_wrapper_widget, active_button_wrapper_widget, is_turned_on):
|
def checkbox_input_mic_threshold_check_callback(is_turned_on):
|
||||||
callFunctionIfCallable(view_variable.CALLBACK_CHECK_MIC_THRESHOLD, is_turned_on)
|
callFunctionIfCallable(view_variable.CALLBACK_CHECK_MIC_THRESHOLD, 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()
|
|
||||||
|
|
||||||
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_mic_host_callback(value):
|
def optionmenu_mic_host_callback(value):
|
||||||
callFunctionIfCallable(view_variable.CALLBACK_SET_MIC_HOST, value)
|
callFunctionIfCallable(view_variable.CALLBACK_SET_MIC_HOST, value)
|
||||||
@@ -102,19 +84,9 @@ def createSettingBox_Mic(setting_box_wrapper, config_window, settings, view_vari
|
|||||||
progressbar_attr_name="sb__progressbar_x_slider__progressbar_mic_energy_threshold",
|
progressbar_attr_name="sb__progressbar_x_slider__progressbar_mic_energy_threshold",
|
||||||
|
|
||||||
passive_button_attr_name="sb__progressbar_x_slider__passive_button_mic_energy_threshold",
|
passive_button_attr_name="sb__progressbar_x_slider__passive_button_mic_energy_threshold",
|
||||||
passive_button_command=lambda e: checkbox_input_mic_threshold_check_callback(
|
passive_button_command=lambda _e: checkbox_input_mic_threshold_check_callback(True),
|
||||||
e,
|
|
||||||
config_window.sb__progressbar_x_slider__passive_button_mic_energy_threshold,
|
|
||||||
config_window.sb__progressbar_x_slider__active_button_mic_energy_threshold,
|
|
||||||
is_turned_on=True,
|
|
||||||
),
|
|
||||||
active_button_attr_name="sb__progressbar_x_slider__active_button_mic_energy_threshold",
|
active_button_attr_name="sb__progressbar_x_slider__active_button_mic_energy_threshold",
|
||||||
active_button_command=lambda e: checkbox_input_mic_threshold_check_callback(
|
active_button_command=lambda _e: checkbox_input_mic_threshold_check_callback(False),
|
||||||
e,
|
|
||||||
config_window.sb__progressbar_x_slider__passive_button_mic_energy_threshold,
|
|
||||||
config_window.sb__progressbar_x_slider__active_button_mic_energy_threshold,
|
|
||||||
is_turned_on=False,
|
|
||||||
),
|
|
||||||
button_image_file=settings.image_file.MIC_ICON
|
button_image_file=settings.image_file.MIC_ICON
|
||||||
)
|
)
|
||||||
config_window.sb__mic_energy_threshold.grid(row=row)
|
config_window.sb__mic_energy_threshold.grid(row=row)
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
from utils import callFunctionIfCallable
|
from utils import callFunctionIfCallable
|
||||||
|
|
||||||
from .._SettingBoxGenerator import _SettingBoxGenerator
|
from .._SettingBoxGenerator import _SettingBoxGenerator
|
||||||
@@ -11,27 +10,9 @@ def createSettingBox_Speaker(setting_box_wrapper, config_window, settings, view_
|
|||||||
createSettingBoxEntry = sbg.createSettingBoxEntry
|
createSettingBoxEntry = sbg.createSettingBoxEntry
|
||||||
|
|
||||||
|
|
||||||
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(is_turned_on):
|
||||||
callFunctionIfCallable(view_variable.CALLBACK_CHECK_SPEAKER_THRESHOLD, is_turned_on)
|
callFunctionIfCallable(view_variable.CALLBACK_CHECK_SPEAKER_THRESHOLD, 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()
|
|
||||||
|
|
||||||
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):
|
def optionmenu_input_speaker_device_callback(value):
|
||||||
callFunctionIfCallable(view_variable.CALLBACK_SET_SPEAKER_DEVICE, value)
|
callFunctionIfCallable(view_variable.CALLBACK_SET_SPEAKER_DEVICE, value)
|
||||||
@@ -84,19 +65,9 @@ def createSettingBox_Speaker(setting_box_wrapper, config_window, settings, view_
|
|||||||
progressbar_attr_name="sb__progressbar_x_slider__progressbar_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_attr_name="sb__progressbar_x_slider__passive_button_speaker_energy_threshold",
|
||||||
passive_button_command=lambda e: checkbox_input_speaker_threshold_check_callback(
|
passive_button_command=lambda _e: checkbox_input_speaker_threshold_check_callback(True),
|
||||||
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_attr_name="sb__progressbar_x_slider__active_button_speaker_energy_threshold",
|
||||||
active_button_command=lambda e: checkbox_input_speaker_threshold_check_callback(
|
active_button_command=lambda _e: checkbox_input_speaker_threshold_check_callback(False),
|
||||||
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_file=settings.image_file.HEADPHONES_ICON
|
button_image_file=settings.image_file.HEADPHONES_ICON
|
||||||
)
|
)
|
||||||
config_window.sb__speaker_energy_threshold.grid(row=row)
|
config_window.sb__speaker_energy_threshold.grid(row=row)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from customtkinter import CTk
|
|||||||
|
|
||||||
# from .ui_managers import ColorThemeManager, ImageFileManager, UiScalingManager
|
# from .ui_managers import ColorThemeManager, ImageFileManager, UiScalingManager
|
||||||
from ._changeMainWindowWidgetsStatus import _changeMainWindowWidgetsStatus
|
from ._changeMainWindowWidgetsStatus import _changeMainWindowWidgetsStatus
|
||||||
|
from ._changeConfigWindowWidgetsStatus import _changeConfigWindowWidgetsStatus
|
||||||
from ._printToTextbox import _printToTextbox
|
from ._printToTextbox import _printToTextbox
|
||||||
|
|
||||||
from .main_window import createMainWindowWidgets
|
from .main_window import createMainWindowWidgets
|
||||||
@@ -62,6 +63,15 @@ class VRCT_GUI(CTk):
|
|||||||
target_names=target_names,
|
target_names=target_names,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def changeConfigWindowWidgetsStatus(self, status, target_names):
|
||||||
|
_changeConfigWindowWidgetsStatus(
|
||||||
|
config_window=self.config_window,
|
||||||
|
settings=self.settings.config_window,
|
||||||
|
view_variable=self._view_variable,
|
||||||
|
status=status,
|
||||||
|
target_names=target_names,
|
||||||
|
)
|
||||||
|
|
||||||
def printToTextbox(self, target_textbox, original_message, translated_message, tags=None):
|
def printToTextbox(self, target_textbox, original_message, translated_message, tags=None):
|
||||||
_printToTextbox(
|
_printToTextbox(
|
||||||
settings=self.settings.main,
|
settings=self.settings.main,
|
||||||
|
|||||||
Reference in New Issue
Block a user