""" Panel Header Widget Reusable header component for panels with title and optional status indicator. """ from PyQt5.QtWidgets import QWidget, QHBoxLayout, QLabel from PyQt5.QtCore import Qt from PyQt5.QtGui import QFont class PanelHeader(QWidget): """ Header widget for panels with colored background and status indicator. Args: title: Header title text color: Background color hex code show_status: Whether to show status indicator status: Status type ('online', 'offline', 'processing') """ def __init__(self, title: str, color: str = "#34495e", show_status: bool = False, status: str = "offline", parent=None): super().__init__(parent) self.status_indicator = None self.init_ui(title, color, show_status, status) def init_ui(self, title: str, color: str, show_status: bool, status: str): """Initialize the header UI.""" self.setFixedHeight(25) self.setStyleSheet(f""" QWidget {{ background-color: {color}; border-top-left-radius: 5px; border-top-right-radius: 5px; }} """) layout = QHBoxLayout(self) layout.setContentsMargins(10, 0, 10, 0) layout.setSpacing(5) # Title label title_label = QLabel(title) title_label.setFont(QFont("Arial", 10, QFont.Bold)) title_label.setStyleSheet("color: white;") layout.addWidget(title_label) layout.addStretch() # Status indicator if show_status: self.status_indicator = QLabel("●") self.status_indicator.setFont(QFont("Arial", 12)) self.set_status(status) layout.addWidget(self.status_indicator) def set_status(self, status: str): """ Update the status indicator. Args: status: Status type ('online', 'offline', 'processing') """ if self.status_indicator: status_colors = { "online": "#27ae60", "offline": "#e74c3c", "processing": "#f39c12" } color = status_colors.get(status, "#95a5a6") self.status_indicator.setStyleSheet(f"color: {color};")