add image paths
This commit is contained in:
@ -11,6 +11,7 @@ from PySide6.QtGui import QPixmap
|
||||
from PySide6.QtCore import Qt
|
||||
|
||||
import resources.resources_rc
|
||||
from utils.image_paths import ImagePaths
|
||||
|
||||
# 传送系统控件 (包括传送带 和 料斗)
|
||||
class ConveyorSystemWidget(QWidget):
|
||||
@ -51,7 +52,7 @@ class ConveyorSystemWidget(QWidget):
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
|
||||
# 外框图片
|
||||
outer_img = ":/icons/images/料斗1.png"
|
||||
outer_img = ImagePaths.HOPPER1
|
||||
outer_pixmap = QPixmap(outer_img)
|
||||
if outer_pixmap.isNull():
|
||||
print(f"警告:图片 {outer_img} 加载失败,请检查路径!")
|
||||
@ -70,7 +71,7 @@ class ConveyorSystemWidget(QWidget):
|
||||
layout.addWidget(upper_bg_widget, alignment=Qt.AlignCenter)
|
||||
|
||||
# 内框图片
|
||||
inner_img = ":/icons/images/料斗2.png"
|
||||
inner_img = ImagePaths.HOPPER2
|
||||
inner_pixmap = QPixmap(inner_img)
|
||||
if not inner_pixmap.isNull():
|
||||
upper_inner_label = QLabel(upper_bg_widget)
|
||||
@ -86,7 +87,7 @@ class ConveyorSystemWidget(QWidget):
|
||||
group.setObjectName("conveyorGroup")
|
||||
|
||||
# 1. 加载传送带图片,设置group的尺寸和背景
|
||||
conveyor_path = ":/icons/images/传送带.png" # 需要替换为实际的路径
|
||||
conveyor_path = ImagePaths.CONVEYOR # 需要替换为实际的路径
|
||||
conveyor_pix = QPixmap(conveyor_path)
|
||||
if conveyor_pix.isNull():
|
||||
print("警告:传送带图片加载失败!请检查图片路径是否正确!")
|
||||
@ -109,7 +110,7 @@ class ConveyorSystemWidget(QWidget):
|
||||
|
||||
# 3. 左侧齿轮(直接放在group的布局里,层级在背景之上)
|
||||
left_gear = QLabel(group)
|
||||
left_gear_pix = QPixmap(":/icons/images/传送带齿轮.png")
|
||||
left_gear_pix = QPixmap(ImagePaths.CONVEYOR_GEAR)
|
||||
if left_gear_pix.isNull():
|
||||
print("警告:左侧齿轮图片加载失败!")
|
||||
else:
|
||||
@ -120,7 +121,7 @@ class ConveyorSystemWidget(QWidget):
|
||||
|
||||
# 4. 右侧齿轮(通过addStretch推到最右边)
|
||||
right_gear = QLabel(group)
|
||||
right_gear_pix = QPixmap(":/icons/images/传送带齿轮.png")
|
||||
right_gear_pix = QPixmap(ImagePaths.CONVEYOR_GEAR)
|
||||
if right_gear_pix.isNull():
|
||||
print("警告:右侧齿轮图片加载失败!")
|
||||
else:
|
||||
@ -139,40 +140,42 @@ class ConveyorSystemWidget(QWidget):
|
||||
# 左侧按钮
|
||||
self.left_btn = QPushButton()
|
||||
self.left_btn.setFixedSize(25, 25)
|
||||
self.left_btn.setCursor(Qt.PointingHandCursor)
|
||||
self.left_btn.setStyleSheet(
|
||||
"""
|
||||
QPushButton {
|
||||
background-image: url(:/icons/images/传送带箭头按钮左1.png);
|
||||
f"""
|
||||
QPushButton {{
|
||||
background-image: url({ImagePaths.CONVEYOR_ARROW_LEFT1});
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
border: none;
|
||||
}
|
||||
QPushButton:hover {
|
||||
background-image: url(:/icons/images/传送带箭头按钮左2.png);
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background-image: url(:/icons/images/传送带箭头按钮左2.png);
|
||||
}
|
||||
}}
|
||||
QPushButton:hover {{
|
||||
background-image: url({ImagePaths.CONVEYOR_ARROW_LEFT2});
|
||||
}}
|
||||
QPushButton:pressed {{
|
||||
background-image: url({ImagePaths.CONVEYOR_ARROW_LEFT2});
|
||||
}}
|
||||
"""
|
||||
)
|
||||
|
||||
# 右侧按钮
|
||||
self.right_btn = QPushButton()
|
||||
self.right_btn.setFixedSize(25, 25)
|
||||
self.right_btn.setCursor(Qt.PointingHandCursor)
|
||||
self.right_btn.setStyleSheet(
|
||||
"""
|
||||
QPushButton {
|
||||
background-image: url(:/icons/images/传送带箭头按钮右1.png);
|
||||
f"""
|
||||
QPushButton {{
|
||||
background-image: url({ImagePaths.CONVEYOR_ARROW_RIGHT1});
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
border: none;
|
||||
}
|
||||
QPushButton:hover {
|
||||
background-image: url(:/icons/images/传送带箭头按钮右2.png);
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background-image: url(:/icons/images/传送带箭头按钮右2.png);
|
||||
}
|
||||
}}
|
||||
QPushButton:hover {{
|
||||
background-image: url({ImagePaths.CONVEYOR_ARROW_RIGHT2});
|
||||
}}
|
||||
QPushButton:pressed {{
|
||||
background-image: url({ImagePaths.CONVEYOR_ARROW_RIGHT2});
|
||||
}}
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user