[modify] minor modification
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from os.path import exists
|
||||
from os import getcwd
|
||||
from threading import Thread
|
||||
import tkinter.messagebox
|
||||
import customtkinter
|
||||
@@ -13,7 +14,6 @@ customtkinter.set_window_scaling(1.1) # window geometry dimensions
|
||||
|
||||
|
||||
class App(customtkinter.CTk):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.my_font = customtkinter.CTkFont(family="Consolas", size=16, weight="bold")
|
||||
@@ -70,7 +70,7 @@ class App(customtkinter.CTk):
|
||||
self.label_path = customtkinter.CTkLabel(self.frame_param, width=self.w_param//10, text="Path", font=self.my_font)
|
||||
self.label_path.grid(row=0, column=2, sticky='e', pady=(10, 5))
|
||||
self.entry_path = customtkinter.CTkEntry(self.frame_param, width=680, placeholder_text="数据文件夹路径", font=self.my_font)
|
||||
self.entry_path.grid(row=0, column=3, columnspan=7, padx=(5, 10), pady=(10, 5), sticky='w')
|
||||
self.entry_path.grid(row=0, column=3, columnspan=7, padx=(5, 10), pady=(10, 5), sticky='we')
|
||||
self.entry_path.configure(state='disabled')
|
||||
|
||||
self.label_av = customtkinter.CTkLabel(self.frame_param, width=self.w_param//10, text="AV", font=self.my_font)
|
||||
@@ -122,7 +122,7 @@ class App(customtkinter.CTk):
|
||||
def thread_it(self, func, *args):
|
||||
""" 将函数打包进线程 """
|
||||
self.myThread = Thread(target=func, args=args)
|
||||
self.myThread.daemon = True # 主线程退出就直接让子线程跟随退出,不论是否运行完成。
|
||||
self.myThread.daemon = True # 主线程退出就直接让子线程跟随退出,不论是否运行完成。
|
||||
self.myThread.start()
|
||||
|
||||
def initialization(self):
|
||||
@@ -199,17 +199,13 @@ class App(customtkinter.CTk):
|
||||
|
||||
def write2textbox(self, text, wait=0):
|
||||
if wait != 0:
|
||||
self.textbox.configure(state="normal")
|
||||
self.textbox.insert(index='end', text=text)
|
||||
self.textbox.update()
|
||||
self.textbox.see('end')
|
||||
self.textbox.configure(state="disabled")
|
||||
else:
|
||||
self.textbox.configure(state="normal", text_color='blue')
|
||||
self.textbox.insert(index='end', text=text + '\n')
|
||||
self.textbox.update()
|
||||
self.textbox.see('end')
|
||||
self.textbox.configure(state="disabled")
|
||||
|
||||
def check_param(self):
|
||||
func_name = self.menu_main.get()
|
||||
@@ -251,7 +247,7 @@ class App(customtkinter.CTk):
|
||||
try:
|
||||
_ = float(rc)
|
||||
c3 = True
|
||||
except Exception as Err:
|
||||
except ValueError:
|
||||
c3 = False
|
||||
|
||||
flag = 2 if c1 and c2 and c3 else 0
|
||||
@@ -263,7 +259,6 @@ class App(customtkinter.CTk):
|
||||
|
||||
self.textbox.configure(state='normal')
|
||||
self.textbox.delete(index1='1.0', index2='end')
|
||||
self.textbox.configure(state='disabled')
|
||||
|
||||
flag, *args = self.check_param()
|
||||
func_dict = {1: brake.main, 2: current.main}
|
||||
@@ -271,16 +266,18 @@ class App(customtkinter.CTk):
|
||||
if flag == 1:
|
||||
func_dict[flag](path=args[0], av=args[1], rr=args[2], rpm=args[3], axis=args[4], vel=args[5], trq=args[6], w2t=self.write2textbox)
|
||||
elif flag == 2:
|
||||
func_dict[flag](path=args[0], rc=args[1], sub_func= args[2])
|
||||
func_dict[flag](path=args[0], rc=args[1], sub_func=args[2])
|
||||
else:
|
||||
tkinter.messagebox.showerror(title="参数错误", message="请检查对应参数是否填写正确!", )
|
||||
|
||||
self.textbox.configure(state='disabled')
|
||||
|
||||
def func_check_callback(self):
|
||||
flag, *args = self.check_param()
|
||||
if flag:
|
||||
tkinter.messagebox.showinfo(title="参数正确", message="所有参数形式上填写无误,请确定后开始运行!")
|
||||
tkinter.messagebox.showinfo(title="参数正确", message="所有参数形式上填写无误,可以开始运行!")
|
||||
else:
|
||||
tkinter.messagebox.showerror(title="参数错误", message="请检查对应参数是否填写正确!", )
|
||||
tkinter.messagebox.showerror(title="参数错误", message="需要检查对应参数是否填写正确!", )
|
||||
|
||||
def func_log_callback(self):
|
||||
content = self.textbox.get(index1='1.0', index2='end')
|
||||
@@ -290,7 +287,7 @@ class App(customtkinter.CTk):
|
||||
log_name = f"{now}_aio.log"
|
||||
with open(f'{log_name}', 'w', encoding='utf-8') as objlog:
|
||||
objlog.write(content)
|
||||
tkinter.messagebox.showinfo(title="保存成功", message=f'{log_name}已被保存存至↓↓↓\n{os.getcwd()}')
|
||||
tkinter.messagebox.showinfo(title="保存成功", message=f'{log_name}已被保存存至↓↓↓\n{getcwd()}')
|
||||
|
||||
except Exception as Err:
|
||||
print(Err)
|
||||
|
||||
Reference in New Issue
Block a user