[Update] modelでconfigにセットしていた部分をcallbackとしてmainでセットするように変更

This commit is contained in:
misyaguziya
2023-09-04 05:04:37 +09:00
parent 9be2ca29a1
commit b014b1f3cc
2 changed files with 19 additions and 10 deletions

17
main.py
View File

@@ -143,6 +143,15 @@ def callbackSelectedLanguagePresetTab(selected_tab_no):
config.TARGET_COUNTRY = country
config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE)
def callbackSetAuthKeys(keys):
config.AUTH_KEYS = keys
def callbackChangeStatusOSC(value):
config.ENABLE_OSC = value
def callbackChangeStatusSoftwareUpdated(value):
config.UPDATE_FLAG = value
# command func
def callbackToggleTranslation(is_turned_on):
config.ENABLE_TRANSLATION = is_turned_on
@@ -230,7 +239,7 @@ def callbackSetDeeplAuthkey(value):
print("callbackSetDeeplAuthkey", str(value))
# config.AUTH_KEYS["DeepL(auth)"] = str(value)
# if len(value) > 0:
# if model.authenticationTranslator(choice_translator="DeepL(auth)", auth_key=value) is True:
# if model.authenticationTranslator(callbackSetAuthKeys, choice_translator="DeepL(auth)", auth_key=value) is True:
# print_textbox(self.parent.textbox_message_log, "Auth key update completed", "INFO")
# print_textbox(self.parent.textbox_message_system_log, "Auth key update completed", "INFO")
# else:
@@ -352,7 +361,7 @@ def callbackSetOscPort(value):
view.createGUI()
# init config
if model.authenticationTranslator() is False:
if model.authenticationTranslator(callbackSetAuthKeys) is False:
# error update Auth key
view.printToTextbox_AuthenticationError()
@@ -360,10 +369,10 @@ if model.authenticationTranslator() is False:
model.addKeywords()
# check OSC started
model.checkOSCStarted()
model.checkOSCStarted(callbackChangeStatusOSC)
# check Software Updated
model.checkSoftwareUpdated()
model.checkSoftwareUpdated(callbackChangeStatusSoftwareUpdated)
# init logger
if config.ENABLE_LOGGER is True:

View File

@@ -68,7 +68,7 @@ class Model:
del self.translator
self.keyword_processor = KeywordProcessor()
def authenticationTranslator(self, choice_translator=None, auth_key=None):
def authenticationTranslator(self, fnc, choice_translator=None, auth_key=None):
if choice_translator == None:
choice_translator = config.CHOICE_TRANSLATOR
if auth_key == None:
@@ -78,7 +78,7 @@ class Model:
if result:
auth_keys = config.AUTH_KEYS
auth_keys[choice_translator] = auth_key
config.AUTH_KEYS = auth_keys
fnc(auth_key)
return result
def startLogger(self):
@@ -165,10 +165,10 @@ class Model:
sendMessage(message, config.OSC_IP_ADDRESS, config.OSC_PORT)
@staticmethod
def checkOSCStarted():
def checkOSCStarted(fnc):
def checkOscReceive(address, osc_arguments):
if config.ENABLE_OSC is False:
config.ENABLE_OSC = True
fnc(True)
# start receive osc
th_receive_osc_parameters = Thread(target=receiveOscParameters, args=(checkOscReceive,))
@@ -179,12 +179,12 @@ class Model:
sendTestAction()
@staticmethod
def checkSoftwareUpdated():
def checkSoftwareUpdated(fnc):
# check update
response = requests_get(config.GITHUB_URL)
tag_name = response.json()["tag_name"]
if tag_name != config.VERSION:
config.UPDATE_FLAG = True
fnc(True)
@staticmethod
def getListInputHost():