[aio.py]: 新增tabview组件,区分数据处理和自动化测试功能
This commit is contained in:
parent
8e64d18fb8
commit
412c7c2600
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
|||||||
./test.py
|
test.py
|
||||||
.idea/
|
.idea/
|
||||||
aio/.idea/
|
aio/.idea/
|
||||||
aio/__pycache__/
|
aio/__pycache__/
|
||||||
|
91
aio/aio.py
91
aio/aio.py
@ -12,7 +12,7 @@ customtkinter.set_appearance_mode("System") # Modes: "System" (standard), "Dark
|
|||||||
customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"
|
customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"
|
||||||
customtkinter.set_widget_scaling(1.1) # widget dimensions and text size
|
customtkinter.set_widget_scaling(1.1) # widget dimensions and text size
|
||||||
customtkinter.set_window_scaling(1.1) # window geometry dimensions
|
customtkinter.set_window_scaling(1.1) # window geometry dimensions
|
||||||
socket.setdefaulttimeout(1)
|
socket.setdefaulttimeout(10)
|
||||||
# global vars
|
# global vars
|
||||||
btns = {
|
btns = {
|
||||||
'start': {'btn': '', 'row': 1, 'text': '开始运行'},
|
'start': {'btn': '', 'row': 1, 'text': '开始运行'},
|
||||||
@ -21,23 +21,23 @@ btns = {
|
|||||||
'end': {'btn': '', 'row': 4, 'text': '结束运行'},
|
'end': {'btn': '', 'row': 4, 'text': '结束运行'},
|
||||||
}
|
}
|
||||||
widgits = {
|
widgits = {
|
||||||
'path': {'label': '', 'entry': '', 'row': 0, 'col': 2, 'text': '数据文件夹路径'},
|
'path': {'label': '', 'entry': '', 'row': 1, 'col': 2, 'text': '数据文件夹路径'},
|
||||||
'av': {'label': '', 'entry': '', 'row': 1, 'col': 2, 'text': '角速度'},
|
'av': {'label': '', 'entry': '', 'row': 2, 'col': 2, 'text': '角速度'},
|
||||||
'rc': {'label': '', 'entry': '', 'row': 1, 'col': 4, 'text': 'optional'},
|
'rc': {'label': '', 'entry': '', 'row': 2, 'col': 4, 'text': 'optional'},
|
||||||
'rpm': {'label': '', 'entry': '', 'row': 1, 'col': 6, 'text': '额定转速'},
|
'rpm': {'label': '', 'entry': '', 'row': 2, 'col': 6, 'text': '额定转速'},
|
||||||
'rr': {'label': '', 'entry': '', 'row': 1, 'col': 8, 'text': '减速比'},
|
'rr': {'label': '', 'entry': '', 'row': 2, 'col': 8, 'text': '减速比'},
|
||||||
'dur': {'label': '', 'entry': '', 'row': 1, 'col': 10, 'text': '周期时间'},
|
'dur': {'label': '', 'entry': '', 'row': 2, 'col': 10, 'text': '周期时间'},
|
||||||
'axis': {'label': '', 'optionmenu': '', 'row': 2, 'col': 2, 'text': ''},
|
'axis': {'label': '', 'optionmenu': '', 'row': 3, 'col': 2, 'text': ''},
|
||||||
'vel': {'label': '', 'optionmenu': '', 'row': 2, 'col': 4, 'text': ''},
|
'vel': {'label': '', 'optionmenu': '', 'row': 3, 'col': 4, 'text': ''},
|
||||||
'trq': {'label': '', 'optionmenu': '', 'row': 2, 'col': 6, 'text': ''},
|
'trq': {'label': '', 'optionmenu': '', 'row': 3, 'col': 6, 'text': ''},
|
||||||
'trqh': {'label': '', 'optionmenu': '', 'row': 2, 'col': 8, 'text': ''},
|
'trqh': {'label': '', 'optionmenu': '', 'row': 3, 'col': 8, 'text': ''},
|
||||||
'sto': {'label': '', 'optionmenu': '', 'row': 2, 'col': 10, 'text': ''},
|
'sto': {'label': '', 'optionmenu': '', 'row': 3, 'col': 10, 'text': ''},
|
||||||
'rc1': {'label': '', 'entry': '', 'row': 3, 'col': 2, 'text': '额定电流'},
|
'rc1': {'label': '', 'entry': '', 'row': 4, 'col': 2, 'text': '额定电流'},
|
||||||
'rc2': {'label': '', 'entry': '', 'row': 3, 'col': 4, 'text': '额定电流'},
|
'rc2': {'label': '', 'entry': '', 'row': 4, 'col': 4, 'text': '额定电流'},
|
||||||
'rc3': {'label': '', 'entry': '', 'row': 3, 'col': 6, 'text': '额定电流'},
|
'rc3': {'label': '', 'entry': '', 'row': 4, 'col': 6, 'text': '额定电流'},
|
||||||
'rc4': {'label': '', 'entry': '', 'row': 3, 'col': 8, 'text': '额定电流'},
|
'rc4': {'label': '', 'entry': '', 'row': 4, 'col': 8, 'text': '额定电流'},
|
||||||
'rc5': {'label': '', 'entry': '', 'row': 3, 'col': 10, 'text': '额定电流'},
|
'rc5': {'label': '', 'entry': '', 'row': 4, 'col': 10, 'text': '额定电流'},
|
||||||
'rc6': {'label': '', 'entry': '', 'row': 3, 'col': 12, 'text': '额定电流'},
|
'rc6': {'label': '', 'entry': '', 'row': 4, 'col': 12, 'text': '额定电流'},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ class App(customtkinter.CTk):
|
|||||||
self.geometry("1180x550+30+30")
|
self.geometry("1180x550+30+30")
|
||||||
self.protocol("WM_DELETE_WINDOW", self.func_end_callback)
|
self.protocol("WM_DELETE_WINDOW", self.func_end_callback)
|
||||||
self.config(bg='#E9E9E9')
|
self.config(bg='#E9E9E9')
|
||||||
self.grid_rowconfigure(4, weight=1)
|
self.grid_rowconfigure(5, weight=1)
|
||||||
self.grid_columnconfigure((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), weight=1)
|
self.grid_columnconfigure((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), weight=1)
|
||||||
self.minsize(1180, 550)
|
self.minsize(1180, 550)
|
||||||
# =====================================================================
|
# =====================================================================
|
||||||
@ -72,51 +72,46 @@ class App(customtkinter.CTk):
|
|||||||
btns['log']['btn'].configure(command=lambda: self.thread_it(self.func_log_callback))
|
btns['log']['btn'].configure(command=lambda: self.thread_it(self.func_log_callback))
|
||||||
btns['end']['btn'].configure(command=lambda: self.thread_it(self.func_end_callback))
|
btns['end']['btn'].configure(command=lambda: self.thread_it(self.func_end_callback))
|
||||||
# create version info
|
# create version info
|
||||||
self.label_version = customtkinter.CTkLabel(self.frame_func, justify='left', text="Vers: 0.1.4\nDate: 06/06/2024", font=self.my_font, text_color="#4F4F4F")
|
self.label_version = customtkinter.CTkLabel(self.frame_func, justify='left', text="Vers: 0.1.5\nDate: 06/12/2024", font=self.my_font, text_color="#4F4F4F")
|
||||||
self.frame_func.rowconfigure(6, weight=1)
|
self.frame_func.rowconfigure(6, weight=1)
|
||||||
self.label_version.grid(row=6, column=0, padx=20, pady=20, sticky='s')
|
self.label_version.grid(row=6, column=0, padx=20, pady=20, sticky='s')
|
||||||
# =====================================================================
|
# =====================================================================
|
||||||
# create frame
|
# create tabviews
|
||||||
self.frame_param = customtkinter.CTkFrame(self, corner_radius=5, fg_color='#E9E9E9', border_width=2, border_color='#CDCDCD')
|
self.tabview = customtkinter.CTkTabview(self, width=10000, height=100, anchor='w', fg_color='#E9E9E9', border_width=2, border_color='#CDCDCD')
|
||||||
self.frame_param.grid(row=0, column=1, rowspan=3, columnspan=13, sticky='new', ipadx=20, ipady=10, padx=10, pady=(5, 10))
|
self.tabview.grid(row=0, column=1, padx=10, pady=5, sticky="nsew")
|
||||||
|
self.tabview.add("Data Process")
|
||||||
|
self.tabview.add("Automatic Test")
|
||||||
# create main menu
|
# create main menu
|
||||||
self.menu_main = customtkinter.CTkOptionMenu(self.frame_param, values=["INIT", "brake", "current", "iso"], font=self.my_font, text_color='yellow', button_color='red', fg_color='green', command=self.func_main_callback)
|
self.menu_main = customtkinter.CTkOptionMenu(self.tabview.tab('Data Process'), values=["INIT", "brake", "current", "iso"], font=self.my_font, text_color='yellow', button_color='red', fg_color='green', command=self.func_main_callback)
|
||||||
self.menu_main.grid(row=0, column=1, sticky='we', padx=(20, 10), pady=(10, 5))
|
self.menu_main.grid(row=1, column=1, sticky='we', padx=5, pady=5)
|
||||||
self.menu_main.set("Start Here!")
|
self.menu_main.set("Start Here!")
|
||||||
# create sub menu
|
# create sub menu
|
||||||
self.menu_sub = customtkinter.CTkOptionMenu(self.frame_param)
|
self.menu_sub = customtkinter.CTkOptionMenu(self.tabview.tab('Data Process'))
|
||||||
# =====================================================================
|
|
||||||
# create path related
|
|
||||||
self.label_path = customtkinter.CTkLabel(self.frame_param, 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=670, placeholder_text="数据文件夹路径", font=self.my_font)
|
|
||||||
self.entry_path.grid(row=0, column=3, columnspan=11, padx=(5, 10), pady=(10, 5), sticky='we')
|
|
||||||
self.entry_path.configure(state='disabled')
|
|
||||||
# =====================================================================
|
# =====================================================================
|
||||||
# create widgits
|
# create widgits
|
||||||
for widgit in widgits:
|
for widgit in widgits:
|
||||||
if widgit == 'path':
|
if widgit == 'path':
|
||||||
widgits[widgit]['label'] = customtkinter.CTkLabel(self.frame_param, text=f'{widgit.upper()}', font=self.my_font)
|
widgits[widgit]['label'] = customtkinter.CTkLabel(self.tabview.tab('Data Process'), text=f'{widgit.upper()}', font=self.my_font)
|
||||||
widgits[widgit]['label'].grid(row=widgits[widgit]['row'], column=widgits[widgit]['col'], sticky='e', pady=(10, 5))
|
widgits[widgit]['label'].grid(row=widgits[widgit]['row'], column=widgits[widgit]['col'], sticky='e', pady=5)
|
||||||
widgits[widgit]['entry'] = customtkinter.CTkEntry(self.frame_param, width=670, placeholder_text=widgits[widgit]['text'], font=self.my_font)
|
widgits[widgit]['entry'] = customtkinter.CTkEntry(self.tabview.tab('Data Process'), width=670, placeholder_text=widgits[widgit]['text'], font=self.my_font)
|
||||||
widgits[widgit]['entry'].grid(row=widgits[widgit]['row'], column=widgits[widgit]['col']+1, columnspan=11, padx=(5, 10), pady=(10, 5), sticky='we')
|
widgits[widgit]['entry'].grid(row=widgits[widgit]['row'], column=widgits[widgit]['col']+1, columnspan=11, padx=(5, 10), pady=5, sticky='we')
|
||||||
widgits[widgit]['entry'].configure(state='disabled')
|
widgits[widgit]['entry'].configure(state='disabled')
|
||||||
elif widgit in ['av', 'rc', 'rpm', 'rr', 'dur', 'rc1', 'rc2', 'rc3', 'rc4', 'rc5', 'rc6']:
|
elif widgit in ['av', 'rc', 'rpm', 'rr', 'dur', 'rc1', 'rc2', 'rc3', 'rc4', 'rc5', 'rc6']:
|
||||||
widgits[widgit]['label'] = customtkinter.CTkLabel(self.frame_param, text=f"{widgit.upper()}", font=self.my_font)
|
widgits[widgit]['label'] = customtkinter.CTkLabel(self.tabview.tab('Data Process'), text=f"{widgit.upper()}", font=self.my_font)
|
||||||
widgits[widgit]['label'].grid(row=widgits[widgit]['row'], column=widgits[widgit]['col'], sticky='e', pady=(5, 5))
|
widgits[widgit]['label'].grid(row=widgits[widgit]['row'], column=widgits[widgit]['col'], sticky='e', pady=5)
|
||||||
widgits[widgit]['entry'] = customtkinter.CTkEntry(self.frame_param, width=self.w_param, placeholder_text=f"{widgits[widgit]['text']}", font=self.my_font)
|
widgits[widgit]['entry'] = customtkinter.CTkEntry(self.tabview.tab('Data Process'), width=self.w_param, placeholder_text=f"{widgits[widgit]['text']}", font=self.my_font)
|
||||||
widgits[widgit]['entry'].grid(row=widgits[widgit]['row'], column=widgits[widgit]['col']+1, padx=(5, 10), pady=(5, 5), sticky='w')
|
widgits[widgit]['entry'].grid(row=widgits[widgit]['row'], column=widgits[widgit]['col']+1, padx=(5, 10), pady=5, sticky='w')
|
||||||
widgits[widgit]['entry'].configure(state='disabled')
|
widgits[widgit]['entry'].configure(state='disabled')
|
||||||
elif widgit in ['axis', 'vel', 'trq', 'trqh', 'sto']:
|
elif widgit in ['axis', 'vel', 'trq', 'trqh', 'sto']:
|
||||||
widgits[widgit]['label'] = customtkinter.CTkLabel(self.frame_param, text=f"{widgit.upper()}", font=self.my_font)
|
widgits[widgit]['label'] = customtkinter.CTkLabel(self.tabview.tab('Data Process'), text=f"{widgit.upper()}", font=self.my_font)
|
||||||
widgits[widgit]['label'].grid(row=widgits[widgit]['row'], column=widgits[widgit]['col'], sticky='e', pady=(5, 5))
|
widgits[widgit]['label'].grid(row=widgits[widgit]['row'], column=widgits[widgit]['col'], sticky='e', pady=5)
|
||||||
widgits[widgit]['optionmenu'] = customtkinter.CTkOptionMenu(self.frame_param, button_color='#708090', fg_color='#778899', values=["1", "2", "3", "4", "5", "6", "7"], width=self.w_param, font=self.my_font)
|
widgits[widgit]['optionmenu'] = customtkinter.CTkOptionMenu(self.tabview.tab('Data Process'), button_color='#708090', fg_color='#778899', values=["1", "2", "3", "4", "5", "6", "7"], width=self.w_param, font=self.my_font)
|
||||||
widgits[widgit]['optionmenu'].grid(row=widgits[widgit]['row'], column=widgits[widgit]['col']+1, padx=(5, 10), pady=(5, 5), sticky='w')
|
widgits[widgit]['optionmenu'].grid(row=widgits[widgit]['row'], column=widgits[widgit]['col']+1, padx=(5, 10), pady=5, sticky='w')
|
||||||
widgits[widgit]['optionmenu'].configure(state='disabled')
|
widgits[widgit]['optionmenu'].configure(state='disabled')
|
||||||
# =====================================================================
|
# =====================================================================
|
||||||
# create textbox
|
# create textbox
|
||||||
self.textbox = customtkinter.CTkTextbox(self, wrap='none', font=customtkinter.CTkFont(family="consolas", size=14), text_color="blue", fg_color='#E9E9E9', border_width=2, border_color='#CDCDCD', border_spacing=5)
|
self.textbox = customtkinter.CTkTextbox(self, wrap='none', font=customtkinter.CTkFont(family="consolas", size=14), text_color="blue", fg_color='#E9E9E9', border_width=2, border_color='#CDCDCD', border_spacing=5)
|
||||||
self.textbox.grid(row=4, column=1, rowspan=3, columnspan=13, ipadx=10, ipady=10, padx=10, pady=(5, 10), sticky='nsew')
|
self.textbox.grid(row=5, column=1, rowspan=2, columnspan=13, ipadx=10, ipady=10, padx=10, pady=(5, 10), sticky='nsew')
|
||||||
self.textbox.configure(state='disabled')
|
self.textbox.configure(state='disabled')
|
||||||
# =====================================================================
|
# =====================================================================
|
||||||
# version check
|
# version check
|
||||||
@ -161,8 +156,8 @@ class App(customtkinter.CTk):
|
|||||||
widgits[widgit]['label'].configure(text_color="red")
|
widgits[widgit]['label'].configure(text_color="red")
|
||||||
widgits[widgit]['optionmenu'].configure(state='normal')
|
widgits[widgit]['optionmenu'].configure(state='normal')
|
||||||
elif func_name == 'current':
|
elif func_name == 'current':
|
||||||
self.menu_sub = customtkinter.CTkOptionMenu(self.frame_param, values=["max", "avg", "cycle"], font=self.my_font, button_color='red', fg_color='green', command=self.func_sub_callback)
|
self.menu_sub = customtkinter.CTkOptionMenu(self.tabview.tab('Data Process'), values=["max", "avg", "cycle"], font=self.my_font, button_color='red', fg_color='green', command=self.func_sub_callback)
|
||||||
self.menu_sub.grid(row=1, column=1, sticky='we', padx=(20, 10), pady=(5, 5))
|
self.menu_sub.grid(row=2, column=1, sticky='we', padx=5, pady=5)
|
||||||
self.menu_sub.set("--select--")
|
self.menu_sub.set("--select--")
|
||||||
self.menu_sub.configure(text_color='yellow')
|
self.menu_sub.configure(text_color='yellow')
|
||||||
|
|
||||||
|
BIN
aio/layout.xlsx
BIN
aio/layout.xlsx
Binary file not shown.
Reference in New Issue
Block a user