add image paths
This commit is contained in:
@ -10,6 +10,7 @@ from .circular_button import CircularButton
|
||||
from .clamp_widget import ClampWidget
|
||||
|
||||
import resources.resources_rc
|
||||
from utils.image_paths import ImagePaths
|
||||
|
||||
class HopperWidget(QWidget):
|
||||
# 上料斗破拱信号
|
||||
@ -66,10 +67,10 @@ class HopperWidget(QWidget):
|
||||
self.upper_title_label.setAlignment(Qt.AlignCenter)
|
||||
# self.upper_title_label.setStyleSheet("color: #2fd3f2; font-size: 14px; font-weight: bold;")
|
||||
# self.upper_title_label.setStyleSheet("color: #0bffff; font-size: 18px;")
|
||||
self.upper_title_label.setStyleSheet("""
|
||||
self.upper_title_label.setStyleSheet(f"""
|
||||
color: #0bffff;
|
||||
font-size: 18px;
|
||||
background-image: url(:/icons/images/文字标题底.png);
|
||||
background-image: url({ImagePaths.TEXT_TITLE_BG});
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
margin-bottom: 4px;
|
||||
@ -77,7 +78,7 @@ class HopperWidget(QWidget):
|
||||
layout.addWidget(self.upper_title_label, alignment=Qt.AlignCenter)
|
||||
|
||||
# 加载外框图片
|
||||
outer_img = ":/icons/images/料斗1.png"
|
||||
outer_img = ImagePaths.HOPPER1
|
||||
outer_pixmap = QPixmap(outer_img)
|
||||
if outer_pixmap.isNull():
|
||||
print(f"警告:图片 {outer_img} 加载失败,请检查路径!")
|
||||
@ -93,7 +94,7 @@ class HopperWidget(QWidget):
|
||||
|
||||
|
||||
# 内框图片(上位)
|
||||
inner_img = ":/icons/images/料斗2.png"
|
||||
inner_img = ImagePaths.HOPPER2
|
||||
inner_pixmap = QPixmap(inner_img)
|
||||
if not inner_pixmap.isNull():
|
||||
self.upper_inner_label = QLabel(self.upper_bg_widget)
|
||||
@ -102,7 +103,7 @@ class HopperWidget(QWidget):
|
||||
self.upper_inner_label.move(14, 9)
|
||||
|
||||
# 状态图片(上位,绿色)
|
||||
status_img = ":/icons/images/料斗状态绿.png"
|
||||
status_img = ImagePaths.HOPPER_STATUS_GREEN
|
||||
status_pixmap = QPixmap(status_img)
|
||||
if not status_pixmap.isNull():
|
||||
status_pixmap = status_pixmap.scaled(13, 13, Qt.KeepAspectRatio, Qt.SmoothTransformation)
|
||||
@ -113,7 +114,7 @@ class HopperWidget(QWidget):
|
||||
self.upper_status_label.setStyleSheet("background: none;")
|
||||
|
||||
# 破拱图片(上位)
|
||||
arch_img = ":/icons/images/破拱.png"
|
||||
arch_img = ImagePaths.ARCH_BREAK
|
||||
arch_pixmap = QPixmap(arch_img)
|
||||
if not arch_pixmap.isNull():
|
||||
arch_pixmap = arch_pixmap.scaled(16, 13, Qt.KeepAspectRatio, Qt.SmoothTransformation)
|
||||
@ -139,34 +140,6 @@ class HopperWidget(QWidget):
|
||||
self.upper_extra_label.setFixedSize(120, 29)
|
||||
self.upper_extra_label.move(outer_width//2 - 60, outer_height//2 - 13)
|
||||
|
||||
# 料斗夹具图片(上位)
|
||||
# clamp_img = "料斗夹具.png"
|
||||
# clamp_pixmap = QPixmap(clamp_img)
|
||||
# if not clamp_pixmap.isNull():
|
||||
# self.upper_clamp_label = QLabel()
|
||||
# self.upper_clamp_label.setPixmap(clamp_pixmap)
|
||||
# self.upper_clamp_label.setFixedSize(clamp_pixmap.width(), clamp_pixmap.height())
|
||||
# layout.addWidget(self.upper_clamp_label, alignment=Qt.AlignCenter)
|
||||
|
||||
# 料斗夹具图片(上位,固定152x60尺寸,图片自适应缩放)
|
||||
# 注意:目前由于给出的 料斗夹具图片尺寸大了,只能够先缩放,后期图片对了,可以用上面的
|
||||
# clamp_img = "料斗夹具.png"
|
||||
# clamp_pixmap = QPixmap(clamp_img)
|
||||
# if not clamp_pixmap.isNull():
|
||||
# self.upper_clamp_label = QLabel()
|
||||
# # 1. 固定QLabel尺寸为152x60 51,84
|
||||
# self.upper_clamp_label.setFixedSize(152, 60)
|
||||
# # 2. 图片缩放到152x60(保持比例,平滑缩放)
|
||||
# scaled_pixmap = clamp_pixmap.scaled(
|
||||
# 152, 60,
|
||||
# Qt.KeepAspectRatio, # 保持图片原始比例,避免变形
|
||||
# Qt.SmoothTransformation # 平滑缩放,提升显示效果
|
||||
# )
|
||||
# self.upper_clamp_label.setPixmap(scaled_pixmap)
|
||||
# # 3. 确保图片在QLabel中居中显示
|
||||
# self.upper_clamp_label.setAlignment(Qt.AlignCenter)
|
||||
# layout.addWidget(self.upper_clamp_label, alignment=Qt.AlignCenter)
|
||||
|
||||
# 夹具容器
|
||||
self.upper_clamp_widget = ClampWidget()
|
||||
layout.addWidget(self.upper_clamp_widget, alignment=Qt.AlignCenter)
|
||||
@ -246,10 +219,10 @@ class HopperWidget(QWidget):
|
||||
self.lower_title_label.setAlignment(Qt.AlignCenter)
|
||||
# self.lower_title_label.setStyleSheet("color: #2fd3f2; font-size: 14px; font-weight: bold;")
|
||||
# self.lower_title_label.setStyleSheet("color: #0bffff; font-size: 18px;")
|
||||
self.lower_title_label.setStyleSheet("""
|
||||
self.lower_title_label.setStyleSheet(f"""
|
||||
color: #0bffff;
|
||||
font-size: 18px;
|
||||
background-image: url(:/icons/images/文字标题底.png);
|
||||
background-image: url({ImagePaths.TEXT_TITLE_BG});
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
margin-bottom: 4px;
|
||||
@ -257,7 +230,7 @@ class HopperWidget(QWidget):
|
||||
layout.addWidget(self.lower_title_label, alignment=Qt.AlignCenter)
|
||||
|
||||
# 加载外框图片
|
||||
outer_img = ":/icons/images/料斗1.png"
|
||||
outer_img = ImagePaths.HOPPER1
|
||||
outer_pixmap = QPixmap(outer_img)
|
||||
if outer_pixmap.isNull():
|
||||
print(f"警告:图片 {outer_img} 加载失败,请检查路径!")
|
||||
@ -272,7 +245,7 @@ class HopperWidget(QWidget):
|
||||
layout.addWidget(self.lower_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():
|
||||
self.lower_inner_label = QLabel(self.lower_bg_widget)
|
||||
@ -281,7 +254,7 @@ class HopperWidget(QWidget):
|
||||
self.lower_inner_label.move(14, 9)
|
||||
|
||||
# 状态图片(下位)
|
||||
status_img = ":/icons/images/料斗状态绿.png"
|
||||
status_img = ImagePaths.HOPPER_STATUS_GREEN
|
||||
status_pixmap = QPixmap(status_img)
|
||||
if not status_pixmap.isNull():
|
||||
status_pixmap = status_pixmap.scaled(13, 13, Qt.KeepAspectRatio, Qt.SmoothTransformation)
|
||||
@ -292,7 +265,7 @@ class HopperWidget(QWidget):
|
||||
self.lower_status_label.setStyleSheet("background: none;")
|
||||
|
||||
# 破拱图片(下位)
|
||||
arch_img = ":/icons/images/破拱.png"
|
||||
arch_img = ImagePaths.ARCH_BREAK
|
||||
arch_pixmap = QPixmap(arch_img)
|
||||
if not arch_pixmap.isNull():
|
||||
arch_pixmap = arch_pixmap.scaled(16, 13, Qt.KeepAspectRatio, Qt.SmoothTransformation)
|
||||
@ -322,33 +295,6 @@ class HopperWidget(QWidget):
|
||||
# self.lower_extra_label.move(outer_width//2 - 46, outer_height//2 - 20)
|
||||
self.lower_extra_label.move(outer_width//2 - 60, outer_height//2 - 13)
|
||||
|
||||
# 料斗夹具图片(下位)
|
||||
# clamp_img = "料斗夹具.png"
|
||||
# clamp_pixmap = QPixmap(clamp_img)
|
||||
# if not clamp_pixmap.isNull():
|
||||
# self.lower_clamp_label = QLabel()
|
||||
# self.lower_clamp_label.setPixmap(clamp_pixmap)
|
||||
# self.lower_clamp_label.setFixedSize(clamp_pixmap.width(), clamp_pixmap.height())
|
||||
# layout.addWidget(self.lower_clamp_label, alignment=Qt.AlignCenter)
|
||||
|
||||
# 目前由于给出的 料斗夹具图片尺寸大了,只能够先缩放,后期图片对了,可以用上面的
|
||||
# clamp_img = "料斗夹具.png"
|
||||
# clamp_pixmap = QPixmap(clamp_img)
|
||||
# if not clamp_pixmap.isNull():
|
||||
# self.lower_clamp_label = QLabel()
|
||||
# # 1. 固定QLabel尺寸为152x60
|
||||
# self.lower_clamp_label.setFixedSize(152, 60)
|
||||
# # 2. 图片缩放到152x60(保持比例,平滑缩放)
|
||||
# scaled_pixmap = clamp_pixmap.scaled(
|
||||
# 152, 60,
|
||||
# Qt.KeepAspectRatio, # 保持图片原始比例,避免变形
|
||||
# Qt.SmoothTransformation # 平滑缩放,提升显示效果
|
||||
# )
|
||||
# self.lower_clamp_label.setPixmap(scaled_pixmap)
|
||||
# # 3. 确保图片在QLabel中居中显示
|
||||
# self.lower_clamp_label.setAlignment(Qt.AlignCenter)
|
||||
# layout.addWidget(self.lower_clamp_label, alignment=Qt.AlignCenter)
|
||||
|
||||
# 夹具容器
|
||||
self.lower_clamp_widget = ClampWidget()
|
||||
layout.addWidget( self.lower_clamp_widget, alignment=Qt.AlignCenter)
|
||||
@ -405,9 +351,9 @@ class HopperWidget(QWidget):
|
||||
# 状态-图片路径映射
|
||||
# 注意:需要替换为实际的图片路径
|
||||
status_img_map = {
|
||||
0: ":/icons/images/料斗状态绿.png",
|
||||
1: ":/icons/images/料斗状态黄.png",
|
||||
2: ":/icons/images/料斗状态红.png"
|
||||
0: ImagePaths.HOPPER_STATUS_GREEN,
|
||||
1: ImagePaths.HOPPER_STATUS_YELLOW,
|
||||
2: ImagePaths.HOPPER_STATUS_RED
|
||||
}
|
||||
img_path = status_img_map[status]
|
||||
|
||||
@ -435,9 +381,9 @@ class HopperWidget(QWidget):
|
||||
|
||||
# 注意:需要替换为实际的图片路径
|
||||
status_img_map = {
|
||||
0: ":/icons/images/料斗状态绿.png",
|
||||
1: ":/icons/images/料斗状态黄.png",
|
||||
2: ":/icons/images/料斗状态红.png"
|
||||
0: ImagePaths.HOPPER_STATUS_GREEN,
|
||||
1: ImagePaths.HOPPER_STATUS_YELLOW,
|
||||
2: ImagePaths.HOPPER_STATUS_RED
|
||||
}
|
||||
img_path = status_img_map[status]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user