v0.1.7.0(2024/06/26)-初步可用
1. [aio.py] 在detect_network函数中需改查询时间间隔是1s,在tabview_click中增加textbox配置normal的语句 2. [do_brake.py -> btn_functions.py] 新增执行相应函数,并在get_state函数中设置无示教器模式 3. [openapi.py] 新增sock_conn函数,并做连接时的异常处理,新增类参数w2t 4. [aio.py] 修改customtkinter库中C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\customtkinter\windows\widgets\ctk_tabview.py文件,参考https://github.com/TomSchimansky/CustomTkinter/issues/2296,实现修改tabview组件的字体大小,使用原生字体,同时将segmented button字体修改为原生,为了解决segmented button在禁用和启用时,屏幕抖动的问题,并将大小修改为16 5. [aio.py] 修改了segmented_button_callback的实现逻辑,使代码更简洁 6. [aio.py] 修改了在tabview_click函数中对于实例化openapi的动作,使每次切换标签都会重新实例化,也就是每次都会重新连接,修复显示不正确的问题 7. [openapi.py] 新增了socket关闭的函数,并增加msg_id为None的处理逻辑 8. [btn_functions.py] 完善了状态获取的功能,新增告警获取以及功能切换的逻辑
This commit is contained in:
@ -110,7 +110,7 @@ class App(customtkinter.CTk):
|
||||
self.tabview.add("Automatic Test")
|
||||
# create main menu for data process
|
||||
self.menu_main_dp = customtkinter.CTkOptionMenu(self.tabview.tab('Data Process'), values=["init", "brake", "current", "iso", "wavelogger"], font=self.my_font, text_color='yellow', button_color='red', fg_color='green', command=self.func_main_callback)
|
||||
self.menu_main_dp.grid(row=1, column=1, sticky='we', padx=5, pady=5)
|
||||
self.menu_main_dp.grid(row=1, column=1, sticky='we', padx=5, pady=10)
|
||||
self.menu_main_dp.set("Start Here!")
|
||||
# create sub menu for data process
|
||||
self.menu_sub_dp = customtkinter.CTkOptionMenu(self.tabview.tab('Data Process'))
|
||||
@ -123,7 +123,7 @@ class App(customtkinter.CTk):
|
||||
for widgit in widgits_dp:
|
||||
if widgit == 'path':
|
||||
widgits_dp[widgit]['label'] = customtkinter.CTkLabel(self.tabview.tab('Data Process'), text=f'{widgit.upper()}', font=self.my_font)
|
||||
widgits_dp[widgit]['label'].grid(row=widgits_dp[widgit]['row'], column=widgits_dp[widgit]['col'], sticky='e', pady=5)
|
||||
widgits_dp[widgit]['label'].grid(row=widgits_dp[widgit]['row'], column=widgits_dp[widgit]['col'], sticky='e', pady=10)
|
||||
widgits_dp[widgit]['entry'] = customtkinter.CTkEntry(self.tabview.tab('Data Process'), width=670, placeholder_text=widgits_dp[widgit]['text'], font=self.my_font)
|
||||
widgits_dp[widgit]['entry'].grid(row=widgits_dp[widgit]['row'], column=widgits_dp[widgit]['col']+1, columnspan=11, padx=(5, 10), pady=5, sticky='we')
|
||||
widgits_dp[widgit]['entry'].configure(state='disabled')
|
||||
@ -142,11 +142,10 @@ class App(customtkinter.CTk):
|
||||
# For data process tab END =====================================================================
|
||||
# For automatic test tab START =====================================================================
|
||||
# create buttons
|
||||
self.seg_button = customtkinter.CTkSegmentedButton(self.tabview.tab('Automatic Test'), font=self.my_font, command=lambda value='机器状态': self.thread_it(self.segmented_button_callback))
|
||||
self.seg_button = customtkinter.CTkSegmentedButton(self.tabview.tab('Automatic Test'), dynamic_resizing=False, font=customtkinter.CTkFont(size=16, weight='bold'), command=lambda value='机器状态': self.thread_it(self.segmented_button_callback))
|
||||
self.seg_button.grid(row=1, column=2, columnspan=12, padx=(20, 10), pady=(10, 10), sticky="ew")
|
||||
self.seg_button.configure(values=["无效功能", "触发急停", "停止运动", "继续运动", "零点位姿", "机器状态", "告警信息"])
|
||||
self.seg_button.set("无效功能")
|
||||
# self.seg_button.configure(state="disabled")
|
||||
self.seg_button.configure(dynamic_resizing=False, values=["功能切换", "触发急停", "停止运动", "继续运动", "零点位姿", "机器状态", "告警信息"])
|
||||
self.seg_button.set("功能切换")
|
||||
# create progress bar
|
||||
self.progressbar = customtkinter.CTkProgressBar(self.tabview.tab('Automatic Test'))
|
||||
self.progressbar.grid(row=5, column=1, padx=5, pady=5, sticky="ew")
|
||||
@ -196,38 +195,27 @@ class App(customtkinter.CTk):
|
||||
self.myThread.start()
|
||||
|
||||
def segmented_button_callback(self):
|
||||
_btn_funcs = {'get_state': '机器状态', 'warning_info': '告警信息', '3': '4', '5': '6', '7': '8'}
|
||||
value = self.seg_button.get()
|
||||
|
||||
self.seg_button.configure(state='disabled')
|
||||
self.textbox.configure(state='normal')
|
||||
# self.tabview.configure(state='disabled')
|
||||
self.textbox.delete(index1='1.0', index2='end')
|
||||
with open(f'{current_path}/../assets/templates/heartbeat', 'r', encoding='utf-8') as f_h:
|
||||
connection_state = f_h.read().strip()
|
||||
|
||||
match value:
|
||||
case '触发急停':
|
||||
self.textbox.delete(index1='1.0', index2='end')
|
||||
self.write2textbox(f"segment button is triggered: {value}")
|
||||
case '停止运动':
|
||||
self.textbox.delete(index1='1.0', index2='end')
|
||||
self.write2textbox(f"segment button is triggered: {value}")
|
||||
case '继续运动':
|
||||
self.textbox.delete(index1='1.0', index2='end')
|
||||
self.write2textbox(f"segment button is triggered: {value}")
|
||||
case '零点位姿':
|
||||
self.textbox.delete(index1='1.0', index2='end')
|
||||
self.write2textbox(f"segment button is triggered: {value}")
|
||||
case '机器状态':
|
||||
self.textbox.configure(state='normal')
|
||||
self.textbox.delete(index1='1.0', index2='end')
|
||||
with open(f'{current_path}/../assets/templates/heartbeat', 'r', encoding='utf-8') as f_h:
|
||||
connection_state = f_h.read().strip()
|
||||
|
||||
if connection_state == '0':
|
||||
self.write2textbox("无法连接机器人,检查是否已经使用Robot Assist软件连接机器,重试中...")
|
||||
else:
|
||||
do_brake.main(self.hr, 'get_state', self.write2textbox)
|
||||
|
||||
case '告警信息':
|
||||
self.textbox.delete(index1='1.0', index2='end')
|
||||
self.write2textbox(f"segment button is triggered: {value}")
|
||||
if connection_state == '0' and value != '功能切换':
|
||||
self.write2textbox("无法连接机器人,检查是否已经使用Robot Assist软件连接机器,重试中...", 0, 50, 'red')
|
||||
else:
|
||||
for _func in _btn_funcs:
|
||||
if _btn_funcs[_func] == value:
|
||||
btn_functions.main(self.hr, _func, self.write2textbox)
|
||||
break
|
||||
|
||||
self.seg_button.configure(state='normal')
|
||||
self.textbox.configure(state='disable')
|
||||
# self.tabview.configure(state='normal')
|
||||
|
||||
def detect_network(self):
|
||||
with open(f"{current_path}/../assets/templates/heartbeat", "w", encoding='utf-8') as f_h:
|
||||
@ -236,7 +224,7 @@ class App(customtkinter.CTk):
|
||||
with open(f'{current_path}/../assets/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)
|
||||
sleep(1)
|
||||
|
||||
def tabview_click(self):
|
||||
self.initialization()
|
||||
@ -249,10 +237,21 @@ class App(customtkinter.CTk):
|
||||
self.menu_main_dp.set("Start Here!")
|
||||
elif tab_name == 'Automatic Test':
|
||||
self.menu_main_at.set("Start Here!")
|
||||
with open(f"{current_path}/../assets/templates/heartbeat", "r", encoding='utf-8') as f_h:
|
||||
connection_state = f_h.read().strip()
|
||||
if connection_state == '0' or self.hr is None:
|
||||
self.hr = openapi.HmiRequest()
|
||||
self.seg_button.configure(state='normal')
|
||||
with open(f"{current_path}/../assets/templates/heartbeat", "w", encoding='utf-8') as f_h:
|
||||
f_h.write('0')
|
||||
|
||||
self.textbox.configure(state='normal')
|
||||
try:
|
||||
self.hr.close_sock()
|
||||
self.hr = openapi.HmiRequest(self.write2textbox)
|
||||
except:
|
||||
self.hr = openapi.HmiRequest(self.write2textbox)
|
||||
|
||||
# if connection_state == '0' or self.hr is None:
|
||||
# self.textbox.configure(state='normal')
|
||||
# self.hr = openapi.HmiRequest(self.write2textbox)
|
||||
# self.textbox.configure(state='disabled')
|
||||
|
||||
def initialization(self):
|
||||
tab_name = self.tabview.get()
|
||||
@ -283,7 +282,7 @@ class App(customtkinter.CTk):
|
||||
widgits_at[widgit]['optionmenu'].configure(state='normal')
|
||||
widgits_at[widgit]['optionmenu'].set(widgits_at[widgit]['text'])
|
||||
widgits_at[widgit]['optionmenu'].configure(state='disabled')
|
||||
self.seg_button.set("无效按钮")
|
||||
self.seg_button.set("功能切换")
|
||||
|
||||
def func_main_callback(self, func_name):
|
||||
self.initialization()
|
||||
|
Reference in New Issue
Block a user