2024-03-05, bugs fixed for kktix_status.

master
CHUN YU YAO 2024-03-17 15:02:25 +08:00
parent b12494d937
commit 053d7f1b76
4 changed files with 99 additions and 79 deletions

View File

@ -42,7 +42,7 @@ try:
except Exception as exc:
pass
CONST_APP_VERSION = "MaxBot (2024.03.04)"
CONST_APP_VERSION = "MaxBot (2024.03.05)"
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_CONFIG_FILE = "settings.json"

View File

@ -10,9 +10,7 @@ except ImportError:
# for Python3
try:
from tkinter import *
from tkinter import ttk
from tkinter import messagebox
from tkinter import filedialog
from tkinter import filedialog, messagebox, ttk
except Exception as e:
pass
@ -25,7 +23,7 @@ import sys
import threading
import webbrowser
CONST_APP_VERSION = "MaxBot (2024.03.04)"
CONST_APP_VERSION = "MaxBot (2024.03.05)"
CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json"
CONST_MAXBOT_CONFIG_FILE = "settings.json"

View File

@ -11,9 +11,7 @@ except ImportError:
# for Python3
try:
from tkinter import *
from tkinter import ttk
from tkinter import messagebox
from tkinter import filedialog
from tkinter import filedialog, messagebox, ttk
except Exception as e:
pass
@ -25,12 +23,13 @@ import platform
import subprocess
import sys
import threading
import webbrowser
import requests
import time
import webbrowser
from datetime import datetime
CONST_APP_VERSION = "MaxBot (2024.03.04)"
import requests
CONST_APP_VERSION = "MaxBot (2024.03.05)"
CONST_MAXBOT_CONFIG_FILE = "settings.json"
CONST_MAXBOT_KKTIX_CONFIG_FILE = "kktix.json"
@ -845,7 +844,7 @@ def kktix_get_registerStatus(event_code):
print("send reg_info request fail:")
print(exc)
registerStatus = None
registerStatus = ""
if not html_result is None:
status_code = html_result.status_code
#print("status_code:",status_code)
@ -881,8 +880,8 @@ def kktix_get_event_code(url):
def kktix_in_stock_play_sound():
global chk_state_play_ticket_sound
try:
if 'chk_state_play_ticket_sound' in globals():
try:
if bool(chk_state_play_ticket_sound.get()):
btn_preview_sound_clicked()
except Exception as e:
@ -900,16 +899,16 @@ def get_kktix_status_by_url(url):
def update_kktix_status(registerStatus):
global status_variable
try:
if 'status_variable' in globals():
try:
status_variable.set(registerStatus)
except Exception as e:
pass
def append_kktix_status_log(output_log):
global txt_status_log
try:
if 'txt_status_log' in globals():
try:
txt_status_log.insert("1.0", output_log + "\n")
except Exception as e:
pass
@ -972,14 +971,14 @@ def collect_ui_config():
check_interval = 3
config_filepath, config_dict = load_json()
try:
if 'combo_check_interval' in globals():
try:
check_interval = int(combo_check_interval.get().strip())
config_dict["check_interval"] = check_interval
else:
is_ui_ready = False
except Exception as e:
pass
else:
is_ui_ready = False
url = ""
filename = ""

View File

@ -8,10 +8,9 @@ try:
except ImportError:
# for Python3
try:
from tkinter import *
from tkinter import ttk
import tkinter.font as tkfont
from tkinter import messagebox
from tkinter import *
from tkinter import messagebox, ttk
from tkinter.filedialog import asksaveasfilename
except Exception as e:
pass
@ -51,7 +50,7 @@ try:
except Exception as exc:
pass
CONST_APP_VERSION = "MaxBot (2024.03.04)"
CONST_APP_VERSION = "MaxBot (2024.03.05)"
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_CONFIG_FILE = "settings.json"
@ -1198,6 +1197,7 @@ def show_preview_text():
date_array = []
global lbl_online_dictionary_preview_data
if 'lbl_online_dictionary_preview_data' in globals():
try:
lbl_online_dictionary_preview_data.config(text=','.join(date_array))
except Exception as exc:
@ -1245,11 +1245,13 @@ def save_url_to_file(new_remote_url, force_write = False):
def btn_preview_text_clicked():
global txt_remote_url
remote_url = ""
if 'txt_remote_url' in globals():
try:
remote_url = txt_remote_url.get("1.0",END).strip()
except Exception as exc:
pass
remote_url = format_config_keyword_for_json(remote_url)
if len(remote_url) > 0:
url_array = []
try:
@ -2715,28 +2717,43 @@ def check_maxbot_config_unsaved(config_dict):
global txt_resume_keyword_second
try:
date_keyword = ""
if 'txt_date_keyword' in globals():
date_keyword = txt_date_keyword.get("1.0",END).strip()
date_keyword = format_config_keyword_for_json(date_keyword)
area_keyword = ""
if 'txt_area_keyword' in globals():
area_keyword = txt_area_keyword.get("1.0",END).strip()
area_keyword = format_config_keyword_for_json(area_keyword)
keyword_exclude = ""
if 'txt_keyword_exclude' in globals():
keyword_exclude = txt_keyword_exclude.get("1.0",END).strip()
keyword_exclude = format_config_keyword_for_json(keyword_exclude)
idle_keyword = ""
if 'txt_idle_keyword' in globals():
idle_keyword = txt_idle_keyword.get("1.0",END).strip()
idle_keyword = format_config_keyword_for_json(idle_keyword)
resume_keyword = ""
if 'txt_resume_keyword' in globals():
resume_keyword = txt_resume_keyword.get("1.0",END).strip()
resume_keyword = format_config_keyword_for_json(resume_keyword)
idle_keyword_second = ""
if 'txt_idle_keyword_second' in globals():
idle_keyword_second = txt_idle_keyword_second.get("1.0",END).strip()
idle_keyword_second = format_config_keyword_for_json(idle_keyword_second)
resume_keyword_second = ""
if 'txt_resume_keyword_second' in globals():
resume_keyword_second = txt_resume_keyword_second.get("1.0",END).strip()
resume_keyword_second = format_config_keyword_for_json(resume_keyword_second)
highlightthickness = 0
if 'combo_ticket_number' in globals():
if len(combo_ticket_number.get().strip())>0:
if config_dict["ticket_number"] != int(combo_ticket_number.get().strip()):
highlightthickness = 2
@ -2777,10 +2794,10 @@ def check_maxbot_config_unsaved(config_dict):
highlightthickness = 2
txt_resume_keyword_second.config(highlightthickness=highlightthickness, highlightbackground="red")
except Exception as exc:
print(exc)
#print(exc)
pass
def resetful_api_timer():
def settgins_gui_timer():
while True:
btn_preview_text_clicked()
preview_question_text_file()
@ -2823,16 +2840,18 @@ def update_maxbot_runtime_status():
sync_status_to_extension(not is_paused)
try:
global combo_language
global lbl_maxbot_status_data
try:
if 'combo_language' in globals():
new_language = combo_language.get().strip()
language_code=get_language_code_by_name(new_language)
global lbl_maxbot_status_data
maxbot_status = translate[language_code]['status_enabled']
if is_paused:
maxbot_status = translate[language_code]['status_paused']
if 'lbl_maxbot_status_data' in globals():
lbl_maxbot_status_data.config(text=maxbot_status)
global btn_idle
@ -2849,12 +2868,15 @@ def update_maxbot_runtime_status():
last_url = read_last_url_from_file()
if len(last_url) > 60:
last_url=last_url[:60]+"..."
if 'lbl_maxbot_last_url_data' in globals():
lbl_maxbot_last_url_data.config(text=last_url)
global lbl_system_clock_data
system_clock_data = datetime.now()
current_time = system_clock_data.strftime('%H:%M:%S')
#print('Current Time is:', current_time)
global lbl_system_clock_data
if 'lbl_system_clock_data' in globals():
lbl_system_clock_data.config(text=current_time)
except Exception as exc:
@ -3383,6 +3405,7 @@ def preview_question_text_file():
question_text = infile.readline()
global txt_question
if 'txt_question' in globals():
try:
displayed_question_text = txt_question.get("1.0",END).strip()
if displayed_question_text != question_text:
@ -3394,7 +3417,7 @@ def preview_question_text_file():
pass
if __name__ == "__main__":
threading.Thread(target=resetful_api_timer, daemon=True).start()
threading.Thread(target=settgins_gui_timer, daemon=True).start()
threading.Thread(target=web_server, daemon=True).start()
clean_tmp_file()
main_gui()