jiateng_ws/ui/loading_dialog_ui.py

302 lines
10 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 LoadingDialogUI(QDialog):
def __init__(self):
super().__init__()
self.setWindowTitle("上料操作")
self.setFixedSize(550, 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.order_label = QLabel("订单号")
self.order_label.setFont(self.normal_font)
self.order_label.setStyleSheet(label_style)
self.order_label.setFixedWidth(100)
self.order_label.setFixedHeight(45)
self.order_input = QLineEdit()
self.order_input.setFont(self.normal_font)
self.order_input.setPlaceholderText("请扫描订单号")
self.order_input.setStyleSheet(input_style)
self.order_input.setFixedHeight(45)
row1.addWidget(self.order_label)
row1.addWidget(self.order_input, 1)
container_layout.addLayout(row1)
# 添加水平分隔布局
split_layout = QHBoxLayout()
split_layout.setSpacing(0)
left_split = QLabel()
left_split.setFixedWidth(100)
left_split.setFixedHeight(1)
left_split.setStyleSheet("background-color: #e0e0e0;")
right_split = QLabel()
right_split.setFixedHeight(1)
right_split.setStyleSheet("background-color: #e0e0e0;")
split_layout.addWidget(left_split)
split_layout.addWidget(right_split, 1)
container_layout.addLayout(split_layout)
# 第二行:托盘号
row2 = QHBoxLayout()
row2.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)
row2.addWidget(self.tray_label)
row2.addWidget(self.tray_input, 1)
container_layout.addLayout(row2)
# 添加水平分隔布局
split_layout2 = QHBoxLayout()
split_layout2.setSpacing(0)
left_split2 = QLabel()
left_split2.setFixedWidth(100)
left_split2.setFixedHeight(1)
left_split2.setStyleSheet("background-color: #e0e0e0;")
right_split2 = QLabel()
right_split2.setFixedHeight(1)
right_split2.setStyleSheet("background-color: #e0e0e0;")
split_layout2.addWidget(left_split2)
split_layout2.addWidget(right_split2, 1)
container_layout.addLayout(split_layout2)
# 第三行:轴型和托盘料
row3 = QHBoxLayout()
row3.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 = QLineEdit()
self.pallet_tier_value.setFont(self.normal_font)
self.pallet_tier_value.setStyleSheet("""
QLineEdit {
padding: 5px;
background-color: white;
color: #333333;
}
QLineEdit:focus {
border: 1px solid #66afe9;
outline: none;
}
""")
self.pallet_tier_value.setFixedHeight(40)
self.pallet_tier_value.setPlaceholderText(" -- ")
tier_layout.addWidget(self.pallet_tier_label)
tier_layout.addWidget(self.pallet_tier_value, 1)
row3.addLayout(axis_layout, 1)
row3.addLayout(tier_layout, 1)
container_layout.addLayout(row3)
# 第四行:数量和重量
row4 = QHBoxLayout()
row4.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)
row4.addLayout(quantity_layout, 1)
row4.addLayout(weight_layout, 1)
container_layout.addLayout(row4)
# 添加弹性空间
container_layout.addStretch()
# 将容器添加到主布局
self.main_layout.addWidget(container)
def create_buttons(self):
"""创建按钮"""
button_layout = QHBoxLayout()
button_layout.setContentsMargins(0, 10, 0, 0)
self.confirm_button = QPushButton("确认")
self.confirm_button.setFont(self.normal_font)
self.confirm_button.setFixedSize(100, 35)
self.confirm_button.setStyleSheet("""
QPushButton {
background-color: #0078d4;
color: white;
border: none;
border-radius: 4px;
padding: 8px 16px;
font-weight: bold;
}
QPushButton:hover {
background-color: #106ebe;
}
QPushButton:pressed {
background-color: #005a9e;
}
""")
self.cancel_button = QPushButton("取消")
self.cancel_button.setFont(self.normal_font)
self.cancel_button.setFixedSize(100, 35)
self.cancel_button.setStyleSheet("""
QPushButton {
background-color: white;
color: #333333;
border: 1px solid #e0e0e0;
border-radius: 4px;
padding: 8px 16px;
font-weight: bold;
}
QPushButton:hover {
background-color: #f5f5f5;
border-color: #bdbdbd;
}
QPushButton:pressed {
background-color: #e0e0e0;
border-color: #bdbdbd;
}
""")
button_layout.addStretch()
button_layout.addWidget(self.confirm_button)
button_layout.addSpacing(30) # 添加30px的间距
button_layout.addWidget(self.cancel_button)
self.main_layout.addLayout(button_layout)