重构添加统一异常处理
This commit is contained in:
@@ -72,30 +72,26 @@ def check_com_connections(self):
|
||||
try:
|
||||
# 检测TV连接
|
||||
ucd_connected = self.check_port_connection(is_ucd=True)
|
||||
self.root.after(
|
||||
0,
|
||||
lambda: self.update_connection_indicator(
|
||||
self.ucd_status_indicator, ucd_connected
|
||||
),
|
||||
self._dispatch_ui(
|
||||
self.update_connection_indicator,
|
||||
self.ucd_status_indicator, ucd_connected,
|
||||
)
|
||||
|
||||
# 检测CA连接
|
||||
ca_connected = self.check_port_connection(is_ucd=False)
|
||||
self.root.after(
|
||||
0,
|
||||
lambda: self.update_connection_indicator(
|
||||
self.ca_status_indicator, ca_connected
|
||||
),
|
||||
self._dispatch_ui(
|
||||
self.update_connection_indicator,
|
||||
self.ca_status_indicator, ca_connected,
|
||||
)
|
||||
|
||||
# 更新状态栏
|
||||
self.root.after(0, lambda: self.status_var.set("连接检测完成"))
|
||||
self._dispatch_ui(self.status_var.set, "连接检测完成")
|
||||
|
||||
# 重新启用所有控件
|
||||
self.root.after(0, self.enable_com_widgets)
|
||||
self._dispatch_ui(self.enable_com_widgets)
|
||||
except Exception as e:
|
||||
self.root.after(0, lambda: self.log_gui.log(f"连接检测出错: {e}"))
|
||||
self.root.after(0, self.enable_com_widgets)
|
||||
self._dispatch_ui(self.log_gui.log, f"连接检测出错: {e}")
|
||||
self._dispatch_ui(self.enable_com_widgets)
|
||||
|
||||
# 启动线程
|
||||
threading.Thread(target=check_connections, daemon=True).start()
|
||||
|
||||
Reference in New Issue
Block a user