this code "# ui/summary_box.py
from PyQt5.QtWidgets import (
    QFrame, QVBoxLayout, QHBoxLayout, QLabel, 
    QPushButton, QScrollArea, QWidget
)
from PyQt5.QtGui import QFont, QIcon, QPalette, QColor, QLinearGradient, QBrush
from PyQt5.QtCore import Qt, QSize, QTimer, QPropertyAnimation, pyqtProperty

class SummaryBox(QFrame):
    def __init__(self):
        super().__init__()
        self.setObjectName("SummaryBox")
        self.setFixedHeight(200)
        self.setMinimumWidth(500)
        
        # Main layout
        main_layout = QVBoxLayout(self)
        main_layout.setContentsMargins(15, 15, 15, 15)
        main_layout.setSpacing(10)
        
        # Header with title and refresh button
        header = QHBoxLayout()
        
        # Title
        title = QLabel("System Insights")
        title.setFont(QFont("Segoe UI", 12, QFont.Bold))
        title.setStyleSheet("color: #6c9bcf;")
        
        # AI badge
        ai_badge = QLabel("AI-Powered")
        ai_badge.setFont(QFont("Segoe UI", 8, QFont.Bold))
        ai_badge.setStyleSheet("""
            background-color: #8a2be2; 
            color: white;
            padding: 2px 8px;
            border-radius: 10px;
        """)
        
        # Refresh button
        self.refresh_btn = QPushButton()
        self.refresh_btn.setIcon(QIcon("assets/icons/refresh.png"))
        self.refresh_btn.setIconSize(QSize(16, 16))
        self.refresh_btn.setFixedSize(30, 30)
        self.refresh_btn.setToolTip("Refresh insights")
        self.refresh_btn.setStyleSheet("""
            QPushButton {
                background-color: #3a3a4a;
                border-radius: 15px;
            }
            QPushButton:hover {
                background-color: #4a4a5a;
            }
        """)
        
        header.addWidget(title)
        header.addWidget(ai_badge)
        header.addStretch()
        header.addWidget(self.refresh_btn)
        
        # Content area (scrollable)
        scroll_area = QScrollArea()
        scroll_area.setWidgetResizable(True)
        scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        scroll_area.setStyleSheet("border: none; background: transparent;")
        
        # Content widget
        self.content_widget = QWidget()
        self.content_layout = QVBoxLayout(self.content_widget)
        self.content_layout.setContentsMargins(5, 5, 5, 5)
        self.content_layout.setSpacing(8)
        
        # Initial content
        self.summary_label = QLabel(self.get_default_summary())
        self.summary_label.setFont(QFont("Segoe UI", 10))
        self.summary_label.setWordWrap(True)
        self.summary_label.setAlignment(Qt.AlignLeft | Qt.AlignTop)
        self.summary_label.setTextInteractionFlags(Qt.TextSelectableByMouse)
        self.content_layout.addWidget(self.summary_label)
        
        scroll_area.setWidget(self.content_widget)
        
        # Add to main layout
        main_layout.addLayout(header)
        main_layout.addWidget(scroll_area)
        
        # Animation properties
        self.gradient_pos = 0.0
        self.gradient_animation = QPropertyAnimation(self, b"gradientPos")
        self.gradient_animation.setDuration(2000)
        self.gradient_animation.setStartValue(0.0)
        self.gradient_animation.setEndValue(1.0)
        self.gradient_animation.setLoopCount(-1)  # Infinite loop
        
        # Connect refresh button
        self.refresh_btn.clicked.connect(self.animate_refresh)
        
        # Start animation
        self.gradient_animation.start()
        
        # Set initial style
        self.update_style()
    
    def get_gradientPos(self):
        return self.gradient_pos
    
    def set_gradientPos(self, value):
        self.gradient_pos = value
        self.update()
    
    gradientPos = pyqtProperty(float, get_gradientPos, set_gradientPos)
    
    def animate_refresh(self):
        # Create a rotation animation for the refresh button
        self.refresh_btn.setEnabled(False)
        
        # Simulate AI processing
        self.summary_label.setText("Analyzing system data...")
        QTimer.singleShot(1500, self.generate_new_summary)
    
    def generate_new_summary(self):
        # This would normally call the AI summarizer module
        # For now, we'll use sample data
        summaries = [
            "System is running smoothly. CPU usage averaged 45% over the last hour. Memory usage is optimal at 62%. No critical events detected.",
            "Network activity increased by 30% in the last hour. Detected 12 new file modifications. Temperature remains within safe limits.",
            "Application usage shows Chrome as the most active process. Disk I/O is slightly elevated but within normal parameters.",
            "Power events: No unexpected shutdowns detected. System uptime is 3 days, 12 hours. Battery health at 92% capacity.",
            "Security: All processes appear legitimate. No suspicious registry modifications detected in the last 24 hours."
        ]
        
        import random
        new_summary = random.choice(summaries)
        
        # Update with fade animation
        self.summary_label.setText(new_summary)
        self.refresh_btn.setEnabled(True)
    
    def get_default_summary(self):
        return (
            "Welcome to HC Pulse! Your system monitoring companion.\n\n"
            "Initial scan shows:\n"
            "- CPU usage: Normal\n"
            "- Memory utilization: Optimal\n"
            "- Disk health: Good\n"
            "- Network status: Stable\n\n"
            "Click refresh to generate real-time AI insights."
        )
    
    def update_style(self):
        # This would be called when theme changes
        # For now, we'll set a default style
        self.setStyleSheet("""
            #SummaryBox {
                background-color: rgba(40, 40, 50, 200);
                border-radius: 10px;
                border: 1px solid #4a4a5a;
            }
            QLabel {
                color: #e0e0e0;
            }
            QScrollBar:vertical {
                border: none;
                background: #3a3a4a;
                width: 8px;
                margin: 0px 0px 0px 0px;
            }
            QScrollBar::handle:vertical {
                background: #6c9bcf;
                min-height: 20px;
                border-radius: 4px;
            }
            QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {
                height: 0px;
            }
        """)
    
    def paintEvent(self, event):
        super().paintEvent(event)
        
        # Draw animated gradient border
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        
        # Create gradient
        gradient = QLinearGradient(0, 0, self.width(), 0)
        gradient.setColorAt(self.gradient_pos, QColor(100, 150, 230, 150))
        gradient.setColorAt((self.gradient_pos + 0.5) % 1.0, QColor(140, 70, 200, 80))
        
        # Draw border
        pen = QPen(QBrush(gradient), 2)
        painter.setPen(pen)
        painter.drawRoundedRect(self.rect().adjusted(1, 1, -1, -1), 10, 10)"

having issue so i want to add this code "# ui/summary_box.py
from PyQt5.QtWidgets import (
    QFrame, QVBoxLayout, QHBoxLayout, QLabel, 
    QPushButton, QScrollArea, QWidget
)
from PyQt5.QtGui import (
    QFont, QIcon, QPalette, QColor, 
    QLinearGradient, QBrush, QPainter, QPen  # Added QPainter and QPen
)
from PyQt5.QtCore import Qt, QSize, QTimer, QPropertyAnimation, pyqtProperty

class SummaryBox(QFrame):
    def __init__(self):
        super().__init__()
        self.setObjectName("SummaryBox")
        self.setFixedHeight(200)
        self.setMinimumWidth(500)
        
        # ... [rest of the __init__ method remains the same] ...
    
    # ... [other methods remain the same] ...
    
    def paintEvent(self, event):
        super().paintEvent(event)
        
        # Draw animated gradient border
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        
        # Create gradient
        gradient = QLinearGradient(0, 0, self.width(), 0)
        gradient.setColorAt(self.gradient_pos, QColor(100, 150, 230, 150))
        gradient.setColorAt((self.gradient_pos + 0.5) % 1.0, QColor(140, 70, 200, 80))
        
        # Draw border
        pen = QPen(QBrush(gradient), 2)
        painter.setPen(pen)
        painter.drawRoundedRect(self.rect().adjusted(1, 1, -1, -1), 10, 10)"

code The key changes are:

Added QPainter and QPen to the import list from PyQt5.QtGui

Added a call to super().paintEvent(event) at the start of the paintEvent method

This should resolve the NameError you encountered. The gradient border animation should now work properly, giving your summary box that premium animated look.

If you want to simplify the implementation and remove the animation (to avoid potential performance issues), you can replace the paintEvent method with this static version:

python
    def paintEvent(self, event):
        super().paintEvent(event)
        
        # Draw static border
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        
        # Create gradient
        gradient = QLinearGradient(0, 0, self.width(), 0)
        gradient.setColorAt(0, QColor(100, 150, 230, 150))
        gradient.setColorAt(1, QColor(140, 70, 200, 80))
        
        # Draw border
        pen = QPen(QBrush(gradient), 2)
        painter.setPen(pen)
        painter.drawRoundedRect(self.rect().adjusted(1, 1, -1, -1), 10, 10)
This static version will still give you a nice gradient border but without the animated effect.

can you add and give me working whole code back