[modify] minor modification, change write2textbox and using shorter func name

This commit is contained in:
2024-05-30 08:28:59 +08:00
parent 05f461f8c1
commit 9b849897e2
3 changed files with 56 additions and 65 deletions

View File

@@ -1,10 +1,10 @@
import os.path
from os.path import exists
from threading import Thread
import tkinter.messagebox
import customtkinter
import brake
import current
import time
from time import time, strftime, localtime
customtkinter.set_appearance_mode("System") # Modes: "System" (standard), "Dark", "Light"
customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"
@@ -125,7 +125,6 @@ class App(customtkinter.CTk):
self.myThread.daemon = True # 主线程退出就直接让子线程跟随退出,不论是否运行完成。
self.myThread.start()
def initialization(self):
self.label_path.configure(text="Path", text_color="black")
self.label_av.configure(text="AV", text_color="black")
@@ -198,16 +197,8 @@ class App(customtkinter.CTk):
elif func_name == 'avg':
pass
def write2textbox(self, text, exitcode=-1, wait=0):
if exitcode != -1:
self.textbox.configure(state="normal", text_color='red')
self.textbox.insert(index='end', text=text + '\n')
self.textbox.insert(index='end', text=f"Error code:{exitcode},需要解决如上问题,再重新运行程序......")
self.textbox.update()
self.textbox.see('end')
self.textbox.configure(state="disabled")
raise Exception("Something wrong, check needed......")
elif wait != 0:
def write2textbox(self, text, wait=0):
if wait != 0:
self.textbox.configure(state="normal")
self.textbox.insert(index='end', text=text)
self.textbox.update()
@@ -231,8 +222,7 @@ class App(customtkinter.CTk):
trq = self.option_trq.get()
sub_func = self.menu_sub.get()
c1 = os.path.exists(path)
c1 = exists(path)
c2 = av.isdigit()
c3 = rr.isdigit()
c4 = rpm = 1
@@ -255,7 +245,7 @@ class App(customtkinter.CTk):
vel = self.option_vel.get()
trq = self.option_trq.get()
sub_func = self.menu_sub.get()
c1 = os.path.exists(path)
c1 = exists(path)
c2 = sub_func in ['max', 'avg']
try:
@@ -296,7 +286,7 @@ class App(customtkinter.CTk):
content = self.textbox.get(index1='1.0', index2='end')
if len(content) > 1:
try:
now = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
now = strftime('%Y%m%d%H%M%S', localtime(time()))
log_name = f"{now}_aio.log"
with open(f'{log_name}', 'w', encoding='utf-8') as objlog:
objlog.write(content)