V3.0
This commit is contained in:
87
test.py
87
test.py
@ -28,7 +28,7 @@ class StatusMonitor(QWidget):
|
||||
|
||||
# 窗口基础设置
|
||||
self.setWindowTitle("中交三航精准布料浇筑要料系统")
|
||||
self.setGeometry(100, 100, 800, 500) # 设置窗口位置和大小
|
||||
self.setGeometry(100, 100, 850, 500) # 设置窗口位置和大小
|
||||
self.setStyleSheet("background-color: #121212;") # 窗口背景设为深黑色
|
||||
|
||||
# 初始化主布局(垂直布局)
|
||||
@ -83,33 +83,33 @@ class StatusMonitor(QWidget):
|
||||
statusWidget = QWidget()
|
||||
statusLayout = QHBoxLayout(statusWidget)
|
||||
statusLayout.setContentsMargins(0, 0, 0, 0)
|
||||
statusLayout.setSpacing(30)
|
||||
statusLayout.setSpacing(30) # 减小中间空白间距(原30)
|
||||
|
||||
leftGroup = QWidget()
|
||||
leftLayout = QVBoxLayout(leftGroup)
|
||||
leftLayout.setSpacing(15)
|
||||
leftLayout.setContentsMargins(0, 0, 0, 0)
|
||||
leftLayout.setContentsMargins(30, 0, 0, 0) # 左边组左内边距设为20,增加左边留白
|
||||
|
||||
rightGroup = QWidget()
|
||||
rightLayout = QVBoxLayout(rightGroup)
|
||||
rightLayout.setSpacing(15)
|
||||
rightLayout.setContentsMargins(0, 0, 0, 0)
|
||||
rightLayout.setContentsMargins(0, 0, 30, 0) # 右边组右内边距设为20,增加右边留白(若需左边也留白,可设左内边距)
|
||||
|
||||
# 左边5个状态项及对应初始值
|
||||
leftStatusInfo = [
|
||||
{"name": "任务单号", "value": "20250706-01"},
|
||||
{"name": "工程名称", "value": "18号线二期工程"},
|
||||
{"name": "区间段", "value": "DK12+345-DK13+678"},
|
||||
{"name": "坍落度", "value": "180mm"},
|
||||
{"name": "配合比编号", "value": "PB-001"}
|
||||
{"name": "区间段", "value": "停车场工作并上行"},
|
||||
{"name": "坍落度", "value": "50~70 mm"},
|
||||
{"name": "配合比编号", "value": "P2022=001"}
|
||||
]
|
||||
# 右边5个状态项及对应初始值
|
||||
rightStatusInfo = [
|
||||
{"name": "要料状态", "value": "未要料"},
|
||||
{"name": "要料标号", "value": "C50"},
|
||||
{"name": "要料方量", "value": "0m³"},
|
||||
{"name": "要料时间", "value": "无"},
|
||||
{"name": "小车状态", "value": "待命"}
|
||||
{"name": "要料状态", "value": "请求中"},
|
||||
{"name": "要料标号", "value": "C50P12"},
|
||||
{"name": "要料方量", "value": "2m³"},
|
||||
{"name": "要料时间", "value": "2分钟后"},
|
||||
{"name": "小车状态", "value": "移动后"}
|
||||
]
|
||||
self.statusWidgets = []
|
||||
|
||||
@ -125,6 +125,7 @@ class StatusMonitor(QWidget):
|
||||
}
|
||||
""")
|
||||
statusItem.setFixedHeight(80)
|
||||
statusItem.setFixedWidth(320) # 统一加长状态项宽度(原无固定宽度)
|
||||
|
||||
itemLayout = QHBoxLayout(statusItem)
|
||||
itemLayout.setContentsMargins(10, 5, 10, 5)
|
||||
@ -142,21 +143,25 @@ class StatusMonitor(QWidget):
|
||||
|
||||
# 状态名称标签
|
||||
nameLabel = QLabel(info["name"])
|
||||
nameLabel.setFixedWidth(100) # 加宽名称标签(原90)
|
||||
nameLabel.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
nameLabel.setStyleSheet("font-size: 14px; color: #FFFFFF;")
|
||||
nameLabel.setFont(QFont("Microsoft YaHei", 12))
|
||||
|
||||
# 状态值标签(去掉边框)
|
||||
# 状态值标签
|
||||
valueLabel = QLabel(info["value"])
|
||||
valueLabel.setStyleSheet("""
|
||||
QLabel {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
color: #FFFFFF;
|
||||
background-color: #3D3D3D;
|
||||
background-color: #2D2D2D;
|
||||
border: none;
|
||||
padding: 0px;
|
||||
}
|
||||
""")
|
||||
valueLabel.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
valueLabel.setMinimumWidth(80)
|
||||
valueLabel.setMinimumWidth(150) # 加宽值标签(原80)
|
||||
|
||||
itemLayout.addWidget(indicator)
|
||||
itemLayout.addSpacing(10)
|
||||
@ -186,6 +191,7 @@ class StatusMonitor(QWidget):
|
||||
}
|
||||
""")
|
||||
statusItem.setFixedHeight(80)
|
||||
statusItem.setFixedWidth(320) # 统一加长状态项宽度(与左侧一致)
|
||||
|
||||
itemLayout = QHBoxLayout(statusItem)
|
||||
itemLayout.setContentsMargins(10, 5, 10, 5)
|
||||
@ -203,21 +209,25 @@ class StatusMonitor(QWidget):
|
||||
|
||||
# 状态名称标签
|
||||
nameLabel = QLabel(info["name"])
|
||||
nameLabel.setFixedWidth(100) # 加宽名称标签(与左侧一致)
|
||||
nameLabel.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
nameLabel.setStyleSheet("font-size: 14px; color: #FFFFFF;")
|
||||
nameLabel.setFont(QFont("Microsoft YaHei", 12))
|
||||
|
||||
# 状态值标签(去掉边框)
|
||||
# 状态值标签
|
||||
valueLabel = QLabel(info["value"])
|
||||
valueLabel.setStyleSheet("""
|
||||
QLabel {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
color: #FFFFFF;
|
||||
background-color: #3D3D3D;
|
||||
background-color: #2D2D2D;
|
||||
border: none;
|
||||
padding: 0px;
|
||||
}
|
||||
""")
|
||||
valueLabel.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
valueLabel.setMinimumWidth(80)
|
||||
valueLabel.setMinimumWidth(150) # 加宽值标签(与左侧一致)
|
||||
|
||||
itemLayout.addWidget(indicator)
|
||||
itemLayout.addSpacing(10)
|
||||
@ -236,7 +246,7 @@ class StatusMonitor(QWidget):
|
||||
rightLayout.addWidget(statusItem)
|
||||
|
||||
statusLayout.addWidget(leftGroup)
|
||||
statusLayout.addStretch(1)
|
||||
statusLayout.addStretch(0) # 减小中间空白比例(原1)
|
||||
statusLayout.addWidget(rightGroup)
|
||||
|
||||
parent_layout.addWidget(statusWidget)
|
||||
@ -380,17 +390,16 @@ class StatusMonitor(QWidget):
|
||||
widget['status'] = status
|
||||
|
||||
if status:
|
||||
# 状态为"是"时的样式
|
||||
# 状态为"是"时的样式 - 去除边框
|
||||
widget['valueLabel'].setText("是")
|
||||
widget['valueLabel'].setStyleSheet("""
|
||||
QLabel {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
color: #00E676;
|
||||
background-color: #1E3A3A;
|
||||
background-color: #2D2D2D; /* 与父容器相同背景色 */
|
||||
padding: 5px 10px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #00796B;
|
||||
border: none; /* 明确去除边框 */
|
||||
min-width: 60px;
|
||||
}
|
||||
""")
|
||||
@ -402,17 +411,16 @@ class StatusMonitor(QWidget):
|
||||
}
|
||||
""")
|
||||
else:
|
||||
# 状态为"否"时的样式
|
||||
# 状态为"否"时的样式 - 去除边框
|
||||
widget['valueLabel'].setText("否")
|
||||
widget['valueLabel'].setStyleSheet("""
|
||||
QLabel {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
color: #FF5252;
|
||||
background-color: #3D2B2B;
|
||||
background-color: #2D2D2D; /* 与父容器相同背景色 */
|
||||
padding: 5px 10px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #5C3636;
|
||||
border: none; /* 明确去除边框 */
|
||||
min-width: 60px;
|
||||
}
|
||||
""")
|
||||
@ -441,27 +449,28 @@ class StatusMonitor(QWidget):
|
||||
"""重启按钮点击事件"""
|
||||
print("系统正在重启...")
|
||||
self.is_running = False
|
||||
# 重置所有状态为"否"
|
||||
for widget in self.statusWidgets:
|
||||
# 重置所有状态为初始值和样式
|
||||
for i, widget in enumerate(self.statusWidgets):
|
||||
widget['status'] = False
|
||||
widget['valueLabel'].setText("否")
|
||||
# 恢复初始值
|
||||
widget['valueLabel'].setText(widget['initial_value'])
|
||||
# 恢复初始样式(无边框)
|
||||
widget['valueLabel'].setStyleSheet("""
|
||||
QLabel {
|
||||
font-size: 18px;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
color: #FF5252;
|
||||
background-color: #3D2B2B;
|
||||
padding: 5px 10px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #5C3636;
|
||||
min-width: 60px;
|
||||
color: #FFFFFF;
|
||||
background-color: #2D2D2D;
|
||||
border: none;
|
||||
padding: 0px;
|
||||
min-width: 80px;
|
||||
}
|
||||
""")
|
||||
widget['indicator'].setStyleSheet("""
|
||||
QLabel {
|
||||
background-color: #FF5252;
|
||||
background-color: #9E9E9E;
|
||||
border-radius: 10px;
|
||||
border: 2px solid #C62828;
|
||||
border: 2px solid #555555;
|
||||
}
|
||||
""")
|
||||
# 重启后自动开始
|
||||
|
||||
Reference in New Issue
Block a user