添加上料斗、下料斗存在错误信息时(表示付工那边没有连接上重量客户端),状态图标显示没连接,并且重量数据清0

This commit is contained in:
2025-11-17 16:02:46 +08:00
parent ccc794d158
commit cfaf1d5d92
4 changed files with 66 additions and 12 deletions

View File

@ -105,7 +105,8 @@ class WeightDetailsDialog(QDialog):
# 2、创建确认图标
self.check_label = QLabel()
self._update_status_icon(False)
self._update_status_icon1(False)
self._update_status_icon2(False)
weight_layout.addWidget(self.check_label)
weight_layout.setSpacing(50)
@ -197,7 +198,7 @@ class WeightDetailsDialog(QDialog):
for i in range(min(len(self.digit_labels), 6)):
self.digit_labels[i].setText(weight_str[i] if i < len(weight_str) else "0")
def _update_status_icon(self, is_connected):
def _update_status_icon1(self, is_connected):
"""根据连接状态切换图标"""
if not self.check_label:
return
@ -209,6 +210,18 @@ class WeightDetailsDialog(QDialog):
else:
print(f"错误:{icon_path} 加载失败,请检查路径!")
def _update_status_icon2(self, is_error):
"""根据是否有错误信息,切换图标"""
if not self.check_label:
return
icon_path = self.default_icon_path if is_error else self.connected_icon_path
pixmap = QPixmap(icon_path)
if not pixmap.isNull():
self.check_label.setPixmap(pixmap.scaled(
pixmap.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation))
else:
print(f"错误:{icon_path} 加载失败,请检查路径!")
# --------------------
# 清空界面信息的通用方法
# --------------------