add image paths
This commit is contained in:
@ -4,6 +4,7 @@ from PySide6.QtGui import QPixmap, QPainter, QFont, QPen
|
||||
from PySide6.QtCore import Qt, QDateTime, QEvent, QSize
|
||||
from view.widgets.switch_button import SwitchButton
|
||||
import resources.resources_rc
|
||||
from utils.image_paths import ImagePaths
|
||||
|
||||
class BottomControlWidget(QWidget):
|
||||
def __init__(self, parent=None):
|
||||
@ -12,7 +13,7 @@ class BottomControlWidget(QWidget):
|
||||
|
||||
def initUI(self):
|
||||
# 1. 加载背景图并设置控件尺寸
|
||||
bg_path = ":/icons/images/底部背景.png"
|
||||
bg_path = ImagePaths.BOTTOM_BACKGROUND
|
||||
self.bg_pixmap = QPixmap(bg_path)
|
||||
if self.bg_pixmap.isNull():
|
||||
print("警告:底部背景.png 加载失败,请检查路径!")
|
||||
@ -28,26 +29,26 @@ class BottomControlWidget(QWidget):
|
||||
# 3. 逐个添加组件
|
||||
## 3.1 系统诊断按钮(带状态图)
|
||||
self.diagnosis_btn = self.createDiagnosisButton("系统诊断",
|
||||
":/icons/images/底部短按钮1.png",
|
||||
":/icons/images/底部短按钮2.png")
|
||||
ImagePaths.BOTTOM_SHORT_BTN1,
|
||||
ImagePaths.BOTTOM_SHORT_BTN2)
|
||||
main_layout.addWidget(self.diagnosis_btn)
|
||||
|
||||
## 3.2 系统状态消息按钮(长按钮)
|
||||
self.status_msg_btn = self.createLongButton("系统状态消息",
|
||||
":/icons/images/底部长按钮1.png",
|
||||
":/icons/images/底部长按钮2.png")
|
||||
ImagePaths.BOTTOM_LONG_BTN1,
|
||||
ImagePaths.BOTTOM_LONG_BTN2)
|
||||
main_layout.addWidget(self.status_msg_btn)
|
||||
|
||||
## 3.3 预警消息列表按钮(长按钮)
|
||||
self.warning_list_btn = self.createLongButton("预警消息列表",
|
||||
":/icons/images/底部长按钮1.png",
|
||||
":/icons/images/底部长按钮2.png")
|
||||
ImagePaths.BOTTOM_LONG_BTN1,
|
||||
ImagePaths.BOTTOM_LONG_BTN2)
|
||||
main_layout.addWidget(self.warning_list_btn)
|
||||
|
||||
## 3.4 系统中心按钮(短按钮,无状态图)
|
||||
self.center_btn = self.createShortButton("系统中心",
|
||||
":/icons/images/底部短按钮1.png",
|
||||
":/icons/images/底部短按钮2.png")
|
||||
ImagePaths.BOTTOM_SHORT_BTN1,
|
||||
ImagePaths.BOTTOM_SHORT_BTN2)
|
||||
main_layout.addWidget(self.center_btn)
|
||||
|
||||
## 3.5 自动模式(文字+开关)
|
||||
@ -88,7 +89,7 @@ class BottomControlWidget(QWidget):
|
||||
|
||||
# 2. 状态图标(作为按钮的子控件,单独定位)
|
||||
self.status_icon = QLabel(btn)
|
||||
status_pix = QPixmap(":/icons/images/底部系统状态绿.png")
|
||||
status_pix = QPixmap(ImagePaths.BOTTOM_SYSTEM_GREEN)
|
||||
if not status_pix.isNull():
|
||||
self.status_icon.setFixedSize(status_pix.width(), status_pix.height())
|
||||
self.status_icon.setPixmap(status_pix)
|
||||
@ -119,12 +120,12 @@ class BottomControlWidget(QWidget):
|
||||
|
||||
return btn
|
||||
|
||||
def setStatusIcon(self, status, count=0):
|
||||
"""切换状态图标并显示数量"""
|
||||
def set_system_status(self, status, count=0):
|
||||
"""设置系统诊断按钮的状态图标并显示数量"""
|
||||
icon_map = {
|
||||
"normal": ":/icons/images/底部系统状态绿.png",
|
||||
"warning": ":/icons/images/底部系统状态黄.png",
|
||||
"error": ":/icons/images/底部系统状态红.png"
|
||||
"normal": ImagePaths.BOTTOM_SYSTEM_GREEN, # 正常情况
|
||||
"warning": ImagePaths.BOTTOM_SYSTEM_YELLOW, # 警告情况
|
||||
"error": ImagePaths.BOTTOM_SYSTEM_RED # 异常情况
|
||||
}
|
||||
pixmap_path = icon_map.get(status, icon_map["normal"])
|
||||
pixmap = QPixmap(pixmap_path)
|
||||
@ -232,7 +233,7 @@ class BottomControlWidget(QWidget):
|
||||
|
||||
def createAutoModeWidget(self):
|
||||
"""创建自动模式组件"""
|
||||
bg_img = ":/icons/images/底部短按钮1.png"
|
||||
bg_img = ImagePaths.BOTTOM_SHORT_BTN1
|
||||
bg_pix = QPixmap(bg_img)
|
||||
if bg_pix.isNull():
|
||||
print(f"警告:{bg_img} 加载失败")
|
||||
@ -285,7 +286,7 @@ if __name__ == "__main__":
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
widget = BottomControlWidget()
|
||||
widget.setStatusIcon("error", 33)
|
||||
widget.set_system_status("error", 33)
|
||||
widget.show()
|
||||
sys.exit(app.exec())
|
||||
|
||||
Reference in New Issue
Block a user