jiateng_ws/ui/unloading_dialog_ui.py

237 lines
7.8 KiB
Python
Raw Normal View History

from PySide6.QtWidgets import (
QDialog, QLabel, QLineEdit, QComboBox, QPushButton,
QVBoxLayout, QHBoxLayout, QFrame
)
from PySide6.QtCore import Qt
from PySide6.QtGui import QFont
class UnloadingDialogUI(QDialog):
def __init__(self):
super().__init__()
self.setWindowTitle("下料操作")
self.setFixedSize(600, 250) # 减小高度,因为移除了第一行
# 设置字体
self.normal_font = QFont("微软雅黑", 12)
# 初始化UI
self.init_ui()
def init_ui(self):
"""初始化UI"""
# 主布局
self.main_layout = QVBoxLayout(self)
self.main_layout.setContentsMargins(20, 20, 20, 20)
self.main_layout.setSpacing(0) # 移除布局间距
# 创建内容区域
self.create_content_frame()
# 创建按钮
self.create_buttons()
def create_content_frame(self):
"""创建内容区域"""
# 创建一个带边框的容器
container = QFrame()
container.setStyleSheet("""
QFrame {
border: 1px solid #e0e0e0;
background-color: white;
}
""")
# 容器的垂直布局
container_layout = QVBoxLayout(container)
container_layout.setContentsMargins(0, 0, 0, 0)
container_layout.setSpacing(0)
# 通用样式
label_style = """
QLabel {
background-color: #f5f5f5;
color: #333333;
font-weight: bold;
border: none;
border-right: 1px solid #e0e0e0;
border-bottom: 1px solid #e0e0e0;
padding: 0 8px;
}
"""
input_style = """
QLineEdit {
border: none;
border-right: 1px solid #e0e0e0;
border-bottom: 1px solid #e0e0e0;
background-color: white;
selection-background-color: #0078d4;
padding: 0 8px;
}
QLineEdit:focus {
background-color: #f8f8f8;
}
"""
value_style = """
QLabel {
background-color: white;
border: none;
border-right: 1px solid #e0e0e0;
border-bottom: 1px solid #e0e0e0;
padding: 0 8px;
}
"""
# 第一行:托盘号
row1 = QHBoxLayout()
row1.setSpacing(0)
self.tray_label = QLabel("托盘号")
self.tray_label.setFont(self.normal_font)
self.tray_label.setStyleSheet(label_style)
self.tray_label.setFixedWidth(100)
self.tray_label.setFixedHeight(45)
self.tray_input = QLineEdit()
self.tray_input.setFont(self.normal_font)
self.tray_input.setPlaceholderText("请扫描托盘号")
self.tray_input.setStyleSheet(input_style)
self.tray_input.setFixedHeight(45)
row1.addWidget(self.tray_label)
row1.addWidget(self.tray_input, 1)
container_layout.addLayout(row1)
# 第二行:轴型和托盘料
row2 = QHBoxLayout()
row2.setSpacing(0)
axis_layout = QHBoxLayout()
axis_layout.setSpacing(0)
self.axis_label = QLabel("轴型")
self.axis_label.setFont(self.normal_font)
self.axis_label.setStyleSheet(label_style)
self.axis_label.setFixedWidth(100)
self.axis_label.setFixedHeight(40)
self.axis_value = QLabel("--")
self.axis_value.setFont(self.normal_font)
self.axis_value.setStyleSheet(value_style)
self.axis_value.setFixedHeight(40)
axis_layout.addWidget(self.axis_label)
axis_layout.addWidget(self.axis_value, 1)
tier_layout = QHBoxLayout()
tier_layout.setSpacing(0)
self.pallet_tier_label = QLabel("托盘料")
self.pallet_tier_label.setFont(self.normal_font)
self.pallet_tier_label.setStyleSheet(label_style)
self.pallet_tier_label.setFixedWidth(100)
self.pallet_tier_label.setFixedHeight(40)
self.pallet_tier_value = QLabel("--")
self.pallet_tier_value.setFont(self.normal_font)
self.pallet_tier_value.setStyleSheet(value_style)
self.pallet_tier_value.setFixedHeight(40)
tier_layout.addWidget(self.pallet_tier_label)
tier_layout.addWidget(self.pallet_tier_value, 1)
row2.addLayout(axis_layout, 1)
row2.addLayout(tier_layout, 1)
container_layout.addLayout(row2)
# 第三行:数量和重量
row3 = QHBoxLayout()
row3.setSpacing(0)
quantity_layout = QHBoxLayout()
quantity_layout.setSpacing(0)
self.quantity_label = QLabel("数量")
self.quantity_label.setFont(self.normal_font)
self.quantity_label.setStyleSheet(label_style)
self.quantity_label.setFixedWidth(100)
self.quantity_label.setFixedHeight(40)
self.quantity_value = QLabel("--")
self.quantity_value.setFont(self.normal_font)
self.quantity_value.setStyleSheet(value_style)
self.quantity_value.setFixedHeight(40)
quantity_layout.addWidget(self.quantity_label)
quantity_layout.addWidget(self.quantity_value, 1)
weight_layout = QHBoxLayout()
weight_layout.setSpacing(0)
self.weight_label = QLabel("重量")
self.weight_label.setFont(self.normal_font)
self.weight_label.setStyleSheet(label_style)
self.weight_label.setFixedWidth(100)
self.weight_label.setFixedHeight(40)
self.weight_value = QLabel("--")
self.weight_value.setFont(self.normal_font)
self.weight_value.setStyleSheet(value_style)
self.weight_value.setFixedHeight(40)
weight_layout.addWidget(self.weight_label)
weight_layout.addWidget(self.weight_value, 1)
row3.addLayout(quantity_layout, 1)
row3.addLayout(weight_layout, 1)
container_layout.addLayout(row3)
# 添加弹性空间
container_layout.addStretch()
# 将容器添加到主布局
self.main_layout.addWidget(container)
def create_buttons(self):
"""创建按钮"""
# 按钮布局
button_layout = QHBoxLayout()
button_layout.setContentsMargins(0, 20, 0, 0)
button_layout.setSpacing(10)
# 确认按钮
self.confirm_button = QPushButton("确认")
self.confirm_button.setFont(self.normal_font)
self.confirm_button.setStyleSheet("""
QPushButton {
background-color: #fff8e1;
border: 1px solid #ffc107;
padding: 8px 16px;
font-weight: bold;
border-radius: 4px;
}
QPushButton:hover {
background-color: #fff3e0;
}
""")
# 取消按钮
self.cancel_button = QPushButton("取消")
self.cancel_button.setFont(self.normal_font)
self.cancel_button.setStyleSheet("""
QPushButton {
background-color: #f5f5f5;
border: 1px solid #e0e0e0;
padding: 8px 16px;
font-weight: bold;
border-radius: 4px;
}
QPushButton:hover {
background-color: #eeeeee;
}
""")
# 添加按钮到布局
button_layout.addStretch()
button_layout.addWidget(self.confirm_button)
button_layout.addWidget(self.cancel_button)
# 将按钮布局添加到主布局
self.main_layout.addLayout(button_layout)