8. [openapi.py] 增加心跳检测函数,并开启线程执行;取消在该文件中生成实例
9. [aio.py] 完成detect_network,并在main函数开启线程
10. 将templates文件夹移动到assets内
This commit is contained in:
2024-06-23 20:18:41 +08:00
parent 295894a843
commit a4009eb17c
14 changed files with 50 additions and 29 deletions

View File

@ -4,7 +4,7 @@ from os import getcwd
from threading import Thread
import tkinter.messagebox
import customtkinter
from time import time, strftime, localtime
from time import time, strftime, localtime, sleep
from urllib.request import urlopen
from socket import setdefaulttimeout
import data_process.brake as brake
@ -70,9 +70,6 @@ widgits_at = {
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
self.net_detect = Thread(target=self.detect_network)
self.net_detect.daemon = True
self.net_detect.start()
self.my_font = customtkinter.CTkFont(family="Consolas", size=16, weight="bold")
self.w_param = 84
# =====================================================================
@ -209,7 +206,11 @@ class App(customtkinter.CTk):
pass
def detect_network(self):
pass
while True:
with open('./automatic_test/templates/heartbeat', 'r', encoding='utf-8') as f_h:
pb_color = 'green' if f_h.read().strip() == '1' else 'red'
self.progressbar.configure(progress_color=pb_color)
sleep(3)
def thread_it(self, func, *args):
""" 将函数打包进线程 """
@ -489,5 +490,11 @@ class App(customtkinter.CTk):
if __name__ == "__main__":
with open("./automatic_test/templates/heartbeat", "w", encoding='utf-8') as f_h:
f_h.write('0')
aio = App()
aio.net_detect = Thread(target=aio.detect_network)
aio.net_detect.daemon = True
aio.net_detect.start()
aio.mainloop()