[bugfix] CTkEntry系で、入力値に簡易バリデーション追加。
TkinterのVariableを使っているCTkEntryは、型を可能なものはStrings型に。(空文字などint型に変換できずエラーになってしまうので) UI側ではどんな型であれ値であれコントローラへ値を渡し、コントローラが判断して処理するように(CTkEntryにセットしたり値を削除したり)
This commit is contained in:
78
main.py
78
main.py
@@ -293,8 +293,21 @@ def callbackSetMicDevice(value):
|
||||
view.replaceConfigWindowMicThresholdCheckButtonToPassive()
|
||||
|
||||
def callbackSetMicEnergyThreshold(value):
|
||||
print("callbackSetMicEnergyThreshold", int(value))
|
||||
print("callbackSetMicEnergyThreshold", value)
|
||||
try:
|
||||
if 0 > int(value) or int(value) > config.MAX_MIC_ENERGY_THRESHOLD: raise ValueError()
|
||||
except:
|
||||
view.setGuiVariable_MicEnergyThreshold(
|
||||
slider_value=config.INPUT_MIC_ENERGY_THRESHOLD,
|
||||
entry_value=None,
|
||||
)
|
||||
return
|
||||
config.INPUT_MIC_ENERGY_THRESHOLD = int(value)
|
||||
view.setGuiVariable_MicEnergyThreshold(
|
||||
slider_value=config.INPUT_MIC_ENERGY_THRESHOLD,
|
||||
entry_value=str(config.INPUT_MIC_ENERGY_THRESHOLD),
|
||||
)
|
||||
|
||||
|
||||
def callbackSetMicDynamicEnergyThreshold(value):
|
||||
print("callbackSetMicDynamicEnergyThreshold", value)
|
||||
@@ -321,16 +334,34 @@ def callbackCheckMicThreshold(is_turned_on):
|
||||
# view.setConfigWindowCompactModeSwitchStatusToNormal()
|
||||
|
||||
def callbackSetMicRecordTimeout(value):
|
||||
print("callbackSetMicRecordTimeout", int(value))
|
||||
print("callbackSetMicRecordTimeout", value)
|
||||
try:
|
||||
if int(value) < 0: raise ValueError()
|
||||
except:
|
||||
view.setGuiVariable_MicRecordTimeout(delete=True)
|
||||
return
|
||||
config.INPUT_MIC_RECORD_TIMEOUT = int(value)
|
||||
view.setGuiVariable_MicRecordTimeout(str(config.INPUT_MIC_RECORD_TIMEOUT))
|
||||
|
||||
def callbackSetMicPhraseTimeout(value):
|
||||
print("callbackSetMicPhraseTimeout", int(value))
|
||||
print("callbackSetMicPhraseTimeout", value)
|
||||
try:
|
||||
if int(value) < 0: raise ValueError()
|
||||
except:
|
||||
view.setGuiVariable_MicPhraseTimeout(delete=True)
|
||||
return
|
||||
config.INPUT_MIC_PHRASE_TIMEOUT = int(value)
|
||||
view.setGuiVariable_MicPhraseTimeout(str(config.INPUT_MIC_PHRASE_TIMEOUT))
|
||||
|
||||
def callbackSetMicMaxPhrases(value):
|
||||
print("callbackSetMicMaxPhrases", int(value))
|
||||
print("callbackSetMicMaxPhrases", value)
|
||||
try:
|
||||
if int(value) < 0: raise ValueError()
|
||||
except:
|
||||
view.setGuiVariable_MicMaxPhrases(delete=True)
|
||||
return
|
||||
config.INPUT_MIC_MAX_PHRASES = int(value)
|
||||
view.setGuiVariable_MicMaxPhrases(str(config.INPUT_MIC_MAX_PHRASES))
|
||||
|
||||
def callbackSetMicWordFilter(value):
|
||||
print("callbackSetMicWordFilter", value)
|
||||
@@ -354,8 +385,21 @@ def callbackSetSpeakerDevice(value):
|
||||
view.replaceConfigWindowSpeakerThresholdCheckButtonToPassive()
|
||||
|
||||
def callbackSetSpeakerEnergyThreshold(value):
|
||||
print("callbackSetSpeakerEnergyThreshold", int(value))
|
||||
print("callbackSetSpeakerEnergyThreshold", value)
|
||||
try:
|
||||
if 0 > int(value) or int(value) > config.MAX_SPEAKER_ENERGY_THRESHOLD: raise ValueError()
|
||||
except:
|
||||
view.setGuiVariable_SpeakerEnergyThreshold(
|
||||
slider_value=config.INPUT_SPEAKER_ENERGY_THRESHOLD,
|
||||
entry_value=None,
|
||||
)
|
||||
return
|
||||
config.INPUT_SPEAKER_ENERGY_THRESHOLD = int(value)
|
||||
view.setGuiVariable_SpeakerEnergyThreshold(
|
||||
slider_value=config.INPUT_SPEAKER_ENERGY_THRESHOLD,
|
||||
entry_value=str(config.INPUT_SPEAKER_ENERGY_THRESHOLD),
|
||||
)
|
||||
|
||||
|
||||
def callbackSetSpeakerDynamicEnergyThreshold(value):
|
||||
print("callbackSetSpeakerDynamicEnergyThreshold", value)
|
||||
@@ -383,16 +427,34 @@ def callbackCheckSpeakerThreshold(is_turned_on):
|
||||
# view.setConfigWindowCompactModeSwitchStatusToNormal()
|
||||
|
||||
def callbackSetSpeakerRecordTimeout(value):
|
||||
print("callbackSetSpeakerRecordTimeout", int(value))
|
||||
print("callbackSetSpeakerRecordTimeout", value)
|
||||
try:
|
||||
if int(value) < 0: raise ValueError()
|
||||
except:
|
||||
view.setGuiVariable_SpeakerRecordTimeout(delete=True)
|
||||
return
|
||||
config.INPUT_SPEAKER_RECORD_TIMEOUT = int(value)
|
||||
view.setGuiVariable_SpeakerRecordTimeout(str(config.INPUT_SPEAKER_RECORD_TIMEOUT))
|
||||
|
||||
def callbackSetSpeakerPhraseTimeout(value):
|
||||
print("callbackSetSpeakerPhraseTimeout", int(value))
|
||||
print("callbackSetSpeakerPhraseTimeout", value)
|
||||
try:
|
||||
if int(value) < 0: raise ValueError()
|
||||
except:
|
||||
view.setGuiVariable_SpeakerPhraseTimeout(delete=True)
|
||||
return
|
||||
config.INPUT_SPEAKER_PHRASE_TIMEOUT = int(value)
|
||||
view.setGuiVariable_SpeakerPhraseTimeout(str(config.INPUT_SPEAKER_PHRASE_TIMEOUT))
|
||||
|
||||
def callbackSetSpeakerMaxPhrases(value):
|
||||
print("callbackSetSpeakerMaxPhrases", int(value))
|
||||
print("callbackSetSpeakerMaxPhrases", value)
|
||||
try:
|
||||
if int(value) < 0: raise ValueError()
|
||||
except:
|
||||
view.setGuiVariable_SpeakerMaxPhrases(delete=True)
|
||||
return
|
||||
config.INPUT_SPEAKER_MAX_PHRASES = int(value)
|
||||
view.setGuiVariable_SpeakerMaxPhrases(str(config.INPUT_SPEAKER_MAX_PHRASES))
|
||||
|
||||
|
||||
# Others Tab
|
||||
|
||||
Reference in New Issue
Block a user