# coding: utf-8 from PyQt6.QtCore import Qt from PyQt6.QtWidgets import QVBoxLayout from qfluentwidgets import CardWidget, ImageLabel, SubtitleLabel class EmptyCard(CardWidget): def __init__(self, parent=None, text=None): super().__init__(parent=parent) self.setMinimumWidth(200) self.setBorderRadius(10) self.vBoxLayout = QVBoxLayout(self) self.vBoxLayout.setAlignment(Qt.AlignmentFlag.AlignCenter) self.iconLabel = ImageLabel(self) self.iconLabel.setImage(":app/images/empty.png") self.iconLabel.scaledToHeight(130) self.iconLabel.scaledToWidth(130) self.titleLabel = SubtitleLabel(self) self.titleLabel.setText(text) self.titleLabel.setAlignment(Qt.AlignmentFlag.AlignCenter) self.vBoxLayout.addWidget(self.iconLabel, 0, Qt.AlignmentFlag.AlignHCenter) self.vBoxLayout.addWidget(self.titleLabel) def setText(self, text): self.titleLabel.setText(text) self.update() def load(self): self.iconLabel.setImage(":app/images/load.png") self.iconLabel.scaledToHeight(130) self.iconLabel.scaledToWidth(130) self.titleLabel.setText("加载中...") def error(self): self.iconLabel.setImage(":app/images/error.png") self.iconLabel.scaledToHeight(130) self.iconLabel.scaledToWidth(130) self.titleLabel.setText("加载失败,请重试") def empty(self): self.iconLabel.setImage(":app/images/empty.png") self.iconLabel.scaledToHeight(130) self.iconLabel.scaledToWidth(130) self.titleLabel.setText("这里空空如也")