feat:修改上下料区域
This commit is contained in:
parent
976080683f
commit
66344011f4
BIN
db/jtDB.db
BIN
db/jtDB.db
Binary file not shown.
@ -536,30 +536,69 @@ class MainWindowUI(QMainWindow):
|
|||||||
|
|
||||||
self.left_layout.addWidget(self.tray_frame)
|
self.left_layout.addWidget(self.tray_frame)
|
||||||
|
|
||||||
# 下料区 - 使用QFrame包裹,添加边框
|
# 上下料区 - 使用QFrame包裹,添加边框
|
||||||
self.output_frame = QFrame()
|
self.output_frame = QFrame()
|
||||||
self.output_frame.setFrameShape(QFrame.StyledPanel)
|
self.output_frame.setFrameShape(QFrame.StyledPanel)
|
||||||
self.output_frame.setLineWidth(1)
|
self.output_frame.setLineWidth(1)
|
||||||
self.output_frame.setFixedHeight(100) # 压缩下料区域的高度,从原来的150减少到100
|
self.output_frame.setFixedHeight(100) # 保持高度不变
|
||||||
self.output_frame.setStyleSheet("QFrame { background-color: #f8f8f8; }")
|
self.output_frame.setStyleSheet("QFrame { background-color: #f8f8f8; }")
|
||||||
self.output_layout = QHBoxLayout(self.output_frame)
|
self.output_layout = QHBoxLayout(self.output_frame)
|
||||||
self.output_layout.setContentsMargins(0, 0, 0, 0)
|
self.output_layout.setContentsMargins(0, 0, 0, 0)
|
||||||
self.output_layout.setSpacing(0)
|
self.output_layout.setSpacing(0)
|
||||||
|
|
||||||
# 下料区标签
|
# 上料区(拆垛层数)
|
||||||
self.output_label = QLabel("下料")
|
self.input_area = QWidget()
|
||||||
self.output_label.setFont(self.normal_font)
|
self.input_area.setFixedWidth(200) # 设置固定宽度
|
||||||
self.output_label.setAlignment(Qt.AlignCenter)
|
self.input_area.setStyleSheet("background-color: white;")
|
||||||
self.output_label.setFixedWidth(100) # 设置固定宽度
|
self.input_area_layout = QVBoxLayout(self.input_area)
|
||||||
self.output_label.setStyleSheet("background-color: #e0e0e0; border-right: 1px solid #cccccc; font-weight: bold;")
|
self.input_area_layout.setContentsMargins(5, 5, 5, 5)
|
||||||
self.output_layout.addWidget(self.output_label)
|
self.input_area_layout.setSpacing(5)
|
||||||
|
|
||||||
# 下料区内容 - 这里可以添加更多控件
|
# 上料区标签
|
||||||
self.output_content = QWidget()
|
self.input_area_label = QLabel("上料区")
|
||||||
self.output_content.setStyleSheet("background-color: white;")
|
self.input_area_label.setFont(self.normal_font)
|
||||||
self.output_content_layout = QVBoxLayout(self.output_content)
|
self.input_area_label.setAlignment(Qt.AlignCenter)
|
||||||
self.output_content_layout.setContentsMargins(5, 5, 5, 5) # 减小内部边距
|
self.input_area_label.setStyleSheet("font-weight: bold; color: #333333;")
|
||||||
self.output_layout.addWidget(self.output_content)
|
self.input_area_layout.addWidget(self.input_area_label)
|
||||||
|
|
||||||
|
# 拆垛层数显示
|
||||||
|
self.stow_level_label = QLabel("拆垛层数: 1")
|
||||||
|
self.stow_level_label.setFont(self.normal_font)
|
||||||
|
self.stow_level_label.setAlignment(Qt.AlignCenter)
|
||||||
|
self.stow_level_label.setStyleSheet("color: #333333; background-color: #f5f5f5; padding: 5px; border: 1px solid #cccccc; border-radius: 3px;")
|
||||||
|
self.input_area_layout.addWidget(self.stow_level_label)
|
||||||
|
|
||||||
|
self.output_layout.addWidget(self.input_area)
|
||||||
|
|
||||||
|
# 下料区(下料层数、下料位置)
|
||||||
|
self.output_area = QWidget()
|
||||||
|
self.output_area.setStyleSheet("background-color: white;")
|
||||||
|
self.output_area_layout = QVBoxLayout(self.output_area)
|
||||||
|
self.output_area_layout.setContentsMargins(5, 5, 5, 5)
|
||||||
|
self.output_area_layout.setSpacing(5)
|
||||||
|
|
||||||
|
# 下料区标签
|
||||||
|
self.output_area_label = QLabel("下料区")
|
||||||
|
self.output_area_label.setFont(self.normal_font)
|
||||||
|
self.output_area_label.setAlignment(Qt.AlignCenter)
|
||||||
|
self.output_area_label.setStyleSheet("font-weight: bold; color: #333333;")
|
||||||
|
self.output_area_layout.addWidget(self.output_area_label)
|
||||||
|
|
||||||
|
# 下料层数显示
|
||||||
|
self.unload_level_label = QLabel("下料层数: 0/0")
|
||||||
|
self.unload_level_label.setFont(self.normal_font)
|
||||||
|
self.unload_level_label.setAlignment(Qt.AlignCenter)
|
||||||
|
self.unload_level_label.setStyleSheet("color: #333333; background-color: #f5f5f5; padding: 5px; border: 1px solid #cccccc; border-radius: 3px;")
|
||||||
|
self.output_area_layout.addWidget(self.unload_level_label)
|
||||||
|
|
||||||
|
# 下料位置显示
|
||||||
|
self.unload_position_label = QLabel("下料位置: 0")
|
||||||
|
self.unload_position_label.setFont(self.normal_font)
|
||||||
|
self.unload_position_label.setAlignment(Qt.AlignCenter)
|
||||||
|
self.unload_position_label.setStyleSheet("color: #333333; background-color: #f5f5f5; padding: 5px; border: 1px solid #cccccc; border-radius: 3px;")
|
||||||
|
self.output_area_layout.addWidget(self.unload_position_label)
|
||||||
|
|
||||||
|
self.output_layout.addWidget(self.output_area)
|
||||||
|
|
||||||
self.left_layout.addWidget(self.output_frame)
|
self.left_layout.addWidget(self.output_frame)
|
||||||
|
|
||||||
|
|||||||
@ -129,34 +129,6 @@ class MainWindow(MainWindowUI):
|
|||||||
self.material_form_layout = QFormLayout()
|
self.material_form_layout = QFormLayout()
|
||||||
self.material_content_layout.addLayout(self.material_form_layout)
|
self.material_content_layout.addLayout(self.material_form_layout)
|
||||||
|
|
||||||
self.output_form_layout = QFormLayout()
|
|
||||||
self.output_content_layout.addLayout(self.output_form_layout)
|
|
||||||
|
|
||||||
# 为下料区添加占位标签,确保它保持为空
|
|
||||||
self.output_placeholder = QWidget()
|
|
||||||
self.output_placeholder.setStyleSheet("background-color: #f0f0f0;")
|
|
||||||
placeholder_layout = QVBoxLayout(self.output_placeholder)
|
|
||||||
placeholder_layout.setAlignment(Qt.AlignCenter)
|
|
||||||
|
|
||||||
# 添加标题标签
|
|
||||||
title_label = QLabel("下料区")
|
|
||||||
title_label.setAlignment(Qt.AlignCenter)
|
|
||||||
title_label.setStyleSheet("color: #888888;")
|
|
||||||
title_label.setFont(self.second_title_font)
|
|
||||||
placeholder_layout.addWidget(title_label)
|
|
||||||
|
|
||||||
self.output_content_layout.addWidget(self.output_placeholder)
|
|
||||||
|
|
||||||
# 添加下料信息标签
|
|
||||||
self.unloading_level_label = QLabel("下料层数:--")
|
|
||||||
self.unloading_position_label = QLabel("下料位置:--")
|
|
||||||
placeholder_layout.addWidget(self.unloading_level_label)
|
|
||||||
placeholder_layout.addWidget(self.unloading_position_label)
|
|
||||||
self.unloading_level_label.setStyleSheet("color: #888888; font-weight: bold;")
|
|
||||||
self.unloading_position_label.setStyleSheet("color: #888888; font-weight: bold;")
|
|
||||||
self.unloading_level_label.setFont(self.normal_font)
|
|
||||||
self.unloading_position_label.setFont(self.normal_font)
|
|
||||||
|
|
||||||
# 创建堆叠部件
|
# 创建堆叠部件
|
||||||
self.stacked_widget = QStackedWidget()
|
self.stacked_widget = QStackedWidget()
|
||||||
self.stacked_widget.addWidget(self.central_widget) # 主页面
|
self.stacked_widget.addWidget(self.central_widget) # 主页面
|
||||||
@ -1725,47 +1697,26 @@ class MainWindow(MainWindowUI):
|
|||||||
QMessageBox.warning(self, "查询失败", f"检查数据库记录失败: {str(e)}")
|
QMessageBox.warning(self, "查询失败", f"检查数据库记录失败: {str(e)}")
|
||||||
|
|
||||||
def show_operation_status(self, status, operation_type, pallet_type):
|
def show_operation_status(self, status, operation_type, pallet_type):
|
||||||
"""在右上角显示操作状态
|
"""更新上下料区域的状态显示
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
status: 状态文本
|
status: 状态文本
|
||||||
operation_type: 操作类型 (input/output)
|
operation_type: 操作类型 (input/output)
|
||||||
pallet_type: 托盘类型
|
pallet_type: 托盘类型
|
||||||
"""
|
"""
|
||||||
# 确定要添加标签的容器
|
try:
|
||||||
if operation_type == "input":
|
if operation_type == "input":
|
||||||
container = self.material_content
|
# 更新拆垛层数显示
|
||||||
|
if hasattr(self, 'stow_level_label'):
|
||||||
|
self.stow_level_label.setText(f"拆垛层数: {pallet_type}")
|
||||||
|
logging.debug(f"更新拆垛层数显示: {pallet_type}")
|
||||||
else:
|
else:
|
||||||
container = self.output_content
|
# 更新下料层数显示
|
||||||
|
if hasattr(self, 'unload_level_label'):
|
||||||
# 如果已存在状态标签,则移除它
|
self.unload_level_label.setText(f"下料层数: {pallet_type}")
|
||||||
status_label_name = f"{operation_type}_status_label"
|
logging.debug(f"更新下料层数显示: {pallet_type}")
|
||||||
if hasattr(self, status_label_name):
|
except Exception as e:
|
||||||
old_label = getattr(self, status_label_name)
|
logging.error(f"更新状态显示失败: {str(e)}")
|
||||||
old_label.deleteLater()
|
|
||||||
|
|
||||||
# 创建新的状态标签
|
|
||||||
status_label = QLabel(f"{status}: {pallet_type}", container)
|
|
||||||
status_label.setFont(self.second_title_font)
|
|
||||||
status_label.setStyleSheet("color: red; background-color: transparent;")
|
|
||||||
status_label.setAlignment(Qt.AlignRight | Qt.AlignTop)
|
|
||||||
|
|
||||||
# 使用绝对定位,放置在右上角
|
|
||||||
status_label.setGeometry(container.width() - 250, 5, 240, 30)
|
|
||||||
|
|
||||||
# 确保标签始终保持在顶层显示
|
|
||||||
status_label.raise_()
|
|
||||||
status_label.show()
|
|
||||||
|
|
||||||
# 保存标签引用
|
|
||||||
setattr(self, status_label_name, status_label)
|
|
||||||
|
|
||||||
# 保存原始的resize事件处理函数
|
|
||||||
if not hasattr(container, "_original_resize_event"):
|
|
||||||
container._original_resize_event = container.resizeEvent
|
|
||||||
|
|
||||||
# 添加窗口大小变化事件处理,确保标签位置随窗口调整
|
|
||||||
container.resizeEvent = lambda event: self.adjust_status_label_position(event, container, status_label)
|
|
||||||
|
|
||||||
def adjust_status_label_position(self, event, container, label):
|
def adjust_status_label_position(self, event, container, label):
|
||||||
"""调整状态标签位置,确保始终在右上角
|
"""调整状态标签位置,确保始终在右上角
|
||||||
@ -2877,7 +2828,9 @@ class MainWindow(MainWindowUI):
|
|||||||
def handle_unloading_position_ui(self, position):
|
def handle_unloading_position_ui(self, position):
|
||||||
"""在主线程中更新下料位置UI"""
|
"""在主线程中更新下料位置UI"""
|
||||||
try:
|
try:
|
||||||
self.unloading_position_label.setText(f"下料位置:{position}")
|
if hasattr(self, 'unload_position_label'):
|
||||||
|
self.unload_position_label.setText(f"下料位置: {position}")
|
||||||
|
logging.debug(f"更新下料位置显示: {position}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"更新下料位置UI失败: {str(e)}")
|
logging.error(f"更新下料位置UI失败: {str(e)}")
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user