From 66344011f4df5a69112f4c5662f587f9e80fc209 Mon Sep 17 00:00:00 2001 From: zhu-mengmeng <15588200382@163.com> Date: Sat, 19 Jul 2025 14:21:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BF=AE=E6=94=B9=E4=B8=8A=E4=B8=8B?= =?UTF-8?q?=E6=96=99=E5=8C=BA=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/jtDB.db | Bin 192512 -> 192512 bytes ui/main_window_ui.py | 69 +++++++++++++++++++++++++++-------- widgets/main_window.py | 81 +++++++++-------------------------------- 3 files changed, 71 insertions(+), 79 deletions(-) diff --git a/db/jtDB.db b/db/jtDB.db index 31e2b1f1cadea294b1a516787958c7d7b33fb3fc..54892585e8e8022173e8f9003da83efee9817053 100644 GIT binary patch delta 338 zcmZp8z}@hGdxA8h;6xc`RzU{6vhIy3KkXQGC&$^hu?0)=GMh3@p1>xu`JX-82Ie64 zHIvydEL|)pz+NvtNtcDen8V1x$W+(BT-VT2!O+CY$k58bOnj0Kb{RwQN!pk)hNf1= z7UGk%u*(>WPtwF9V`Oe+Y$`rU1DlkUk)`+~bu2Q5R)$8+Nk6tH{a{?QoSC2N>2&r5 zOtMT|Pd5t+?B`+%37#IfmPy9K1gOl))KJgF%)r>x$P3knC{kV_&H*6-My3YlAeGy# JS2G=T0RVZ-Px=4= delta 87 zcmV-d0I2_f;0u7@3y>QD36UH_1qlEyc8RfM`91+AlU_fD22vRf12qDZkOma9{yzq= t14{^ElLye3vk?%)2ZLhxw_^AKqNf863pzr>#YFoW9bEtb diff --git a/ui/main_window_ui.py b/ui/main_window_ui.py index a27207a..328a77c 100644 --- a/ui/main_window_ui.py +++ b/ui/main_window_ui.py @@ -536,30 +536,69 @@ class MainWindowUI(QMainWindow): self.left_layout.addWidget(self.tray_frame) - # 下料区 - 使用QFrame包裹,添加边框 + # 上下料区 - 使用QFrame包裹,添加边框 self.output_frame = QFrame() self.output_frame.setFrameShape(QFrame.StyledPanel) 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_layout = QHBoxLayout(self.output_frame) self.output_layout.setContentsMargins(0, 0, 0, 0) self.output_layout.setSpacing(0) - # 下料区标签 - self.output_label = QLabel("下料") - self.output_label.setFont(self.normal_font) - self.output_label.setAlignment(Qt.AlignCenter) - self.output_label.setFixedWidth(100) # 设置固定宽度 - self.output_label.setStyleSheet("background-color: #e0e0e0; border-right: 1px solid #cccccc; font-weight: bold;") - self.output_layout.addWidget(self.output_label) + # 上料区(拆垛层数) + self.input_area = QWidget() + self.input_area.setFixedWidth(200) # 设置固定宽度 + self.input_area.setStyleSheet("background-color: white;") + self.input_area_layout = QVBoxLayout(self.input_area) + self.input_area_layout.setContentsMargins(5, 5, 5, 5) + self.input_area_layout.setSpacing(5) - # 下料区内容 - 这里可以添加更多控件 - self.output_content = QWidget() - self.output_content.setStyleSheet("background-color: white;") - self.output_content_layout = QVBoxLayout(self.output_content) - self.output_content_layout.setContentsMargins(5, 5, 5, 5) # 减小内部边距 - self.output_layout.addWidget(self.output_content) + # 上料区标签 + self.input_area_label = QLabel("上料区") + self.input_area_label.setFont(self.normal_font) + self.input_area_label.setAlignment(Qt.AlignCenter) + self.input_area_label.setStyleSheet("font-weight: bold; color: #333333;") + 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) diff --git a/widgets/main_window.py b/widgets/main_window.py index ef15f8d..16b50d5 100644 --- a/widgets/main_window.py +++ b/widgets/main_window.py @@ -129,34 +129,6 @@ class MainWindow(MainWindowUI): self.material_form_layout = QFormLayout() 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.addWidget(self.central_widget) # 主页面 @@ -1725,47 +1697,26 @@ class MainWindow(MainWindowUI): QMessageBox.warning(self, "查询失败", f"检查数据库记录失败: {str(e)}") def show_operation_status(self, status, operation_type, pallet_type): - """在右上角显示操作状态 + """更新上下料区域的状态显示 Args: status: 状态文本 operation_type: 操作类型 (input/output) pallet_type: 托盘类型 """ - # 确定要添加标签的容器 - if operation_type == "input": - container = self.material_content - else: - container = self.output_content - - # 如果已存在状态标签,则移除它 - status_label_name = f"{operation_type}_status_label" - if hasattr(self, status_label_name): - old_label = getattr(self, status_label_name) - 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) + try: + if operation_type == "input": + # 更新拆垛层数显示 + if hasattr(self, 'stow_level_label'): + self.stow_level_label.setText(f"拆垛层数: {pallet_type}") + logging.debug(f"更新拆垛层数显示: {pallet_type}") + else: + # 更新下料层数显示 + if hasattr(self, 'unload_level_label'): + self.unload_level_label.setText(f"下料层数: {pallet_type}") + logging.debug(f"更新下料层数显示: {pallet_type}") + except Exception as e: + logging.error(f"更新状态显示失败: {str(e)}") def adjust_status_label_position(self, event, container, label): """调整状态标签位置,确保始终在右上角 @@ -2877,7 +2828,9 @@ class MainWindow(MainWindowUI): def handle_unloading_position_ui(self, position): """在主线程中更新下料位置UI""" 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: logging.error(f"更新下料位置UI失败: {str(e)}")