""" 面板组件 """ from PyQt5.QtWidgets import QFrame, QVBoxLayout, QLabel from PyQt5.QtCore import Qt class PanelWidget(QFrame): """面板组件 - 带标题的容器""" def __init__(self, title: str = "", parent=None): """ 初始化面板 Args: title: 面板标题 parent: 父组件 """ super().__init__(parent) self.title = title self._setup_ui() def _setup_ui(self): """设置UI""" # 设置框架样式 self.setFrameShape(QFrame.StyledPanel) # 创建布局 layout = QVBoxLayout(self) layout.setContentsMargins(15, 15, 15, 15) layout.setSpacing(10) # 添加标题 if self.title: title_label = QLabel(self.title) title_label.setStyleSheet(""" font-size: 16px; font-weight: bold; color: #60a5fa; margin-bottom: 5px; """) layout.addWidget(title_label) # 添加分隔线 line = QFrame() line.setFrameShape(QFrame.HLine) line.setStyleSheet(""" background: rgba(59, 130, 246, 0.2); max-height: 1px; margin-bottom: 10px; """) layout.addWidget(line)