PS C:\Users\Admin\Desktop\projects\testing codes> & C:/Users/Admin/AppData/Local/Programs/Python/Python313/python.exe "c:/Users/Admin/Desktop/projects/testing codes/import sys.py"
QPixmap: Must construct a QGuiApplication before a QPixmap
PS C:\Users\Admin\Desktop\projects\testing codes> 


error in code """"
GST Calculator Desktop App using PyQt6
======================================

Features:
- Modern UI with Material design colors and fonts.
- Smooth animated UI components and hover effects.
- Custom GST Rate input and automatic calculation of CGST, SGST, Total.
- Invoice PDF generation using ReportLab.
- Rotating ad banners inside a visible panel.
- "Ad-Free Upgrade" message to prompt monetization.
- Developer branding visible in settings sidebar.
- Uses Qt Resource System with embedded icons and ad banners (base64).
- Modular and readable code with inline comments.

Usage:
- Run this file locally with Python 3.9+ and PyQt6 installed.
- "Generate Invoice" exports a PDF in the chosen directory.

Packaging: Use PyInstaller for building standalone executable.

Author: Harsh Computronics
Email: <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
Website: hcomputronics.com
"""

import sys
import io
import math
from dataclasses import dataclass
from datetime import datetime
from functools import partial
from PyQt6.QtCore import (
    Qt, QTimer, QEasingCurve, QPropertyAnimation, QRect, QSize, QEvent, pyqtSignal,
)
from PyQt6.QtGui import (
    QAction, QColor, QFont, QFontDatabase, QIcon, QPixmap, QPainter, QBrush,
    QPen, QCursor,
)
from PyQt6.QtWidgets import (
    QApplication, QWidget, QVBoxLayout, QHBoxLayout, QLabel, QPushButton,
    QLineEdit, QTabWidget, QStackedWidget, QFileDialog, QMessageBox, QFrame,
    QSizePolicy, QSpacerItem, QGraphicsDropShadowEffect,
)


# Check if reportlab is installed gracefully
try:
    from reportlab.lib.pagesizes import A4
    from reportlab.lib.units import mm
    from reportlab.pdfgen import canvas
except ImportError:
    QMessageBox = None
    print("Error: 'reportlab' module is not installed.\n"
          "Please install it using:\n\n    pip install reportlab\n")
    # We can define stubs for PDF method to avoid crash but disable functionality.
    def dummy_pdf(*args, **kwargs):
        raise ImportError("reportlab is not installed.")

    A4 = (595.27, 841.89)
    mm = 3.78

    class canvas:
        def __init__(self, *args, **kwargs):
            raise ImportError("reportlab is not installed.")

else:
    QMessageBox = QMessageBox

# ========== EMBEDDED RESOURCES (icons and ad images as base64) ==========

# Material icons SVGs embedded as base64 strings
_ICON_CALCULATE = b"""
PHN2ZyBmaWxsPSIjN2Y4YzlmIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRo
PSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTIgMjFhOSAxMiAw
MTAwLTIwIDEyIDEyIDAgMDAxMiAxMnoiLz48cGF0aCBkPSJNMTMgOWgtMmwtNSA1cy4zLS42LjYtMWwt
My00bDMuNzQtMy43NGExIDEgMCAwMSAxLjQxIDEuNDFMMTggMTJsLTUgNXYtMnoiLz48L3N2Zz4=
"""

_ICON_SAVE = b"""
PHN2ZyBmaWxsPSIjM2JjZGE5IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRo
PSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTcgMkg2YTEgMSAw
MDAgMmgxMHYxMmgtOHYyaDExYTIgMiAwIDAwMi0ydi0xNGExIDEgMCAwMC0xLTF6TTIgOGw0IDRoLThs
NC00em0xMyA2LjVMMTcgOGgzdjdsLTQgNi41ek0xMiA0YTIgMiAwIDExMiAyIDIgMiAwIDAxLTIgMnoi
Lz48L3N2Zz4=
"""

_ICON_SETTINGS = b"""
PHN2ZyBmaWxsPSIjY2NkIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTIgMTQuOGExLjIgMS4yIDAgMSAxIDAgMi40IDEuMiAxLjIgMCAwMSAwLTIuNHptMCA2LjJhNi43IDYuNyAwIDAgMC0zLjItLjZjLS4zIDAtLjYgLjItLjYuN3YxLjZjMCAuNS4zLjcuNi43IDMuNSAwIDMuMi0uMSA0LjcgMi43YTEuMiAxLjIgMCAwMS4xIDIuMmMuMi4yLjUgLjMuOS4zbDQuMi0uMWExLjQgMS40IDAgMDEuNi4xYzAgMCAuMiAxLjItMS4yIDEuNGMtLjYgMC0xLS4yLTEuMy0uNS0uMi0uMy0uNC0uOS0uMy0xLjVsLS4yLTEuYTQuOSA0LjkgMCAwMC0zLjQtLjJ6bS02LjItMy44YTEuNSA1IDEuNCAxLjQgMCAxMC0yLjggMi44IDEuNSAxLjUgMCAwMC0uNCAyLjIgMS40IDEuNCAwIDAwLjYtLjN6Ii8+PC9zdmc+
"""

# Ad banners – here using three placeholder base64 PNGs (solid color rectangles with text)
_AD_BANNERS = [
    # Red banner
    b"""iVBORw0KGgoAAAANSUhEUgAAAMgAAABLCAYAAACDluPuAAAAGXRFWHRTb2Z0d2FyZQBwYWludC5u
ZXQgNC4wLjEyLfNKnQAAAQlJREFUeNrtwTEBAAAAwqD1T20ND6AAAAAAAAAAAAAAAAAAAAAAAAAAAAgL
kEAAQEBAYGBgYGAgICAhISEhITEBAQEBAQEBAQAAAAIAAA==""",
    # Green banner
    b"""iVBORw0KGgoAAAANSUhEUgAAAMgAAABLCAYAAACDluPuAAAAGXRFWHRTb2Z0d2FyZQBwYWludC5u
ZXQgNC4wLjEyLfNKnQAAAQlJREFUeNrtwTEBAAAAwqD1T20ND6AAAAAAAAAAAAAAAAAAAAAAAAAAAAgM
0DAAQEBAYGBgYGAgICAhISEhITEBAQEBAQEBAQAAAAIAAA==""",
    # Blue banner
    b"""iVBORw0KGgoAAAANSUhEUgAAAMgAAABLCAYAAACDluPuAAAAGXRFWHRTb2Z0d2FyZQBwYWludC5u
ZXQgNC4wLjEyLfNKnQAAAQlJREFUeNrtwTEBAAAAwqD1T20ND6AAAAAAAAAAAAAAAAAAAAAAAAAAAAgJ
4EAAQEBAYGBgYGAgICAhISEhITEBAQEBAQEBAQAAAAIAAA==""",
]

# Decode and prepare icons as QIcon objects for reuse
def icon_from_base64(data: bytes) -> QIcon:
    pixmap = QPixmap()
    pixmap.loadFromData(data)
    return QIcon(pixmap)

ICON_CALCULATE = icon_from_base64(_ICON_CALCULATE)
ICON_SAVE = icon_from_base64(_ICON_SAVE)
ICON_SETTINGS = icon_from_base64(_ICON_SETTINGS)


# Decode ad banners as QPixmap list
def banner_pixmaps():
    pixmaps = []
    for b64img in _AD_BANNERS:
        px = QPixmap()
        px.loadFromData(b64img)
        pixmaps.append(px)
    return pixmaps

AD_BANNER_PIXMAPS = banner_pixmaps()

# ========== Colors and Fonts ==========

# Material Indigo, Teal, Light Gray palette (hex)
COLOR_INDIGO = "#3f51b5"
COLOR_TEAL = "#009688"
COLOR_LIGHTGRAY = "#f5f5f5"
COLOR_DARKGRAY = "#424242"
COLOR_WHITE = "#ffffff"
COLOR_BLACK = "#000000"
COLOR_HOVER = "#c5cae9"

# Use Roboto font (or Sans if not available)
def apply_fonts(app):
    # Try to load Roboto from Google Fonts TTF files if bundled or fallback to default
    # For simplicity, we'll use default system sans-serif font with nice size
    font = QFont("Roboto", 10)
    app.setFont(font)

# ========== GST Calculation Logic ==========

@dataclass
class GSTResult:
    cgst: float
    sgst: float
    total: float

def calculate_gst(amount: float, rate_percent: float) -> GSTResult:
    """
    Calculates CGST, SGST based on amount and total GST rate.

    GST rate is split equally for CGST and SGST.
    """
    if amount < 0 or rate_percent < 0:
        return GSTResult(0, 0, 0)

    half_rate = rate_percent / 2
    cgst = amount * half_rate / 100
    sgst = amount * half_rate / 100
    total = amount + cgst + sgst
    return GSTResult(cgst=cgst, sgst=sgst, total=total)

# ========== Animated Hover Button ==========

class HoverButton(QPushButton):
    """
    QPushButton with hover animations and color transitions.
    """

    def __init__(self, text="", icon=None, parent=None):
        super().__init__(text, parent)
        self.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
        self._normal_color = QColor(COLOR_INDIGO)
        self._hover_color = QColor(COLOR_TEAL)
        self._text_color = QColor(COLOR_WHITE)
        self._current_color = self._normal_color
        self.setMinimumHeight(36)
        self.setStyleSheet(self._build_stylesheet())
        if icon:
            self.setIcon(icon)
            self.setIconSize(QSize(18, 18))
        self._animation = QPropertyAnimation(self, b"color", self)
        self._animation.setDuration(200)
        self._animation.setEasingCurve(QEasingCurve.Type.InOutQuad)
        self.color = self._normal_color

    def _build_stylesheet(self):
        return f"""
        QPushButton {{
            background-color: {self._current_color.name()};
            color: {self._text_color.name()};
            border: none;
            border-radius: 4px;
            font-weight: 600;
            padding: 6px 12px;
        }}
        """

    def enterEvent(self, event):
        self.animate_color(self._hover_color)
        return super().enterEvent(event)

    def leaveEvent(self, event):
        self.animate_color(self._normal_color)
        return super().leaveEvent(event)

    def animate_color(self, target_color):
        self._animation.stop()
        self._animation.setStartValue(self._current_color)
        self._animation.setEndValue(target_color)
        self._animation.start()
        self._animation.valueChanged.connect(self._on_color_changed)

    def _on_color_changed(self, color):
        self._current_color = color
        self.setStyleSheet(self._build_stylesheet())

    def get_color(self):
        return self._current_color

    def set_color(self, color):
        self._current_color = color
        self.setStyleSheet(self._build_stylesheet())

    color = pyqtSignal(QColor, name='color', type=QColor)
    color = pyqtSignal(QColor).setter(set_color).getter(get_color)

# ========== Main GST Calculator Widget ==========

class GSTCalculatorWidget(QWidget):
    """
    Main UI Panel for GST Calculation
    """

    invoice_requested = pyqtSignal(GSTResult, float, float)  # total gst, amount, gst rate

    def __init__(self, parent=None):
        super().__init__(parent)
        self.setup_ui()

    def setup_ui(self):
        # Layout root
        layout = QVBoxLayout(self)
        layout.setContentsMargins(36, 36, 36, 36)
        layout.setSpacing(24)

        # Title
        self.title_label = QLabel("GST Calculator")
        self.title_label.setFont(QFont("Roboto", 18, QFont.Weight.Bold))
        self.title_label.setStyleSheet(f"color: {COLOR_INDIGO}")
        layout.addWidget(self.title_label, alignment=Qt.AlignmentFlag.AlignLeft)

        # Amount Input
        self.amount_input = QLineEdit()
        self.amount_input.setPlaceholderText("Enter Amount (₹)")
        self.amount_input.setValidator(self._float_validator())
        self.amount_input.setFont(QFont("Roboto", 12))
        self.amount_input.setStyleSheet(self._input_stylesheet())
        layout.addWidget(self._labeled_widget("Amount", self.amount_input))

        # GST Rate Input
        self.gst_rate_input = QLineEdit()
        self.gst_rate_input.setPlaceholderText("Enter GST Rate (%)")
        self.gst_rate_input.setValidator(self._float_validator())
        self.gst_rate_input.setFont(QFont("Roboto", 12))
        self.gst_rate_input.setStyleSheet(self._input_stylesheet())
        layout.addWidget(self._labeled_widget("GST Rate %", self.gst_rate_input))

        # Calculate Button
        self.calc_button = HoverButton("Calculate", ICON_CALCULATE)
        self.calc_button.setToolTip("Calculate GST Components")
        self.calc_button.clicked.connect(self.on_calculate_clicked)
        layout.addWidget(self.calc_button, alignment=Qt.AlignmentFlag.AlignCenter)

        # Result Labels
        self.result_frame = QFrame()
        result_layout = QVBoxLayout(self.result_frame)
        result_layout.setSpacing(12)

        self.cgst_label = QLabel()
        self.sgst_label = QLabel()
        self.total_label = QLabel()

        for lbl in (self.cgst_label, self.sgst_label, self.total_label):
            lbl.setFont(QFont("Roboto", 14))
            lbl.setStyleSheet(f"color: {COLOR_DARKGRAY}")
            lbl.setTextInteractionFlags(Qt.TextInteractionFlag.TextSelectableByMouse)
            result_layout.addWidget(lbl)

        layout.addWidget(self.result_frame)

        # Generate Invoice Button
        self.invoice_button = HoverButton("Generate Invoice PDF", ICON_SAVE)
        self.invoice_button.setEnabled(False)
        self.invoice_button.clicked.connect(self.on_generate_invoice)
        layout.addWidget(self.invoice_button, alignment=Qt.AlignmentFlag.AlignCenter)

        # Spacer
        layout.addStretch()

        self.gst_result = None

    def _float_validator(self):
        from PyQt6.QtGui import QDoubleValidator
        validator = QDoubleValidator(0.0, 1000000000.0, 2)
        validator.setNotation(QDoubleValidator.Notation.StandardNotation)
        return validator

    def _input_stylesheet(self):
        return f"""
        QLineEdit {{
            border: 1px solid {COLOR_INDIGO};
            border-radius: 4px;
            padding: 6px;
            selection-background-color: {COLOR_TEAL};
            selection-color: {COLOR_WHITE};
            background-color: {COLOR_WHITE};
            color: {COLOR_BLACK};
        }}

        QLineEdit:focus {{
            border: 2px solid {COLOR_TEAL};
            outline: none;
        }}
        """

    def _labeled_widget(self, label_text: str, widget: QWidget) -> QWidget:
        container = QWidget()
        layout = QVBoxLayout(container)
        label = QLabel(label_text)
        label.setFont(QFont("Roboto", 12, QFont.Weight.DemiBold))
        label.setStyleSheet(f"color: {COLOR_INDIGO}")
        layout.addWidget(label)
        layout.addWidget(widget)
        return container

    def on_calculate_clicked(self):
        amount_text = self.amount_input.text().strip()
        gst_rate_text = self.gst_rate_input.text().strip()

        try:
            amount = float(amount_text)
            gst_rate = float(gst_rate_text)
            if amount < 0 or gst_rate < 0:
                raise ValueError
        except ValueError:
            QMessageBox.warning(self, "Invalid Input",
                                "Please enter valid positive numeric values for Amount and GST Rate.")
            return

        # Calculate GST
        result = calculate_gst(amount, gst_rate)
        self.update_result_labels(result, amount, gst_rate)
        self.gst_result = result
        self.invoice_button.setEnabled(True)

    def update_result_labels(self, result: GSTResult, amount: float, gst_rate: float):
        self.cgst_label.setText(f"CGST (@{gst_rate / 2:.2f}%): ₹ {result.cgst:,.2f}")
        self.sgst_label.setText(f"SGST (@{gst_rate / 2:.2f}%): ₹ {result.sgst:,.2f}")
        self.total_label.setText(f"Total Amount (incl. GST): ₹ {result.total:,.2f}")

    def on_generate_invoice(self):
        if not self.gst_result:
            QMessageBox.information(self, "No Data", "Please calculate GST first.")
            return

        options = QFileDialog.Options()
        options |= QFileDialog.Option.DontUseNativeDialog
        filename, _ = QFileDialog.getSaveFileName(
            self,
            "Save Invoice PDF",
            f"GST_Invoice_{datetime.now().strftime('%Y%m%d_%H%M%S')}.pdf",
            "PDF Files (*.pdf)",
            options=options)
        if filename:
            try:
                self._create_invoice_pdf(filename, self.gst_result,
                                         float(self.amount_input.text().strip()),
                                         float(self.gst_rate_input.text().strip()))
                QMessageBox.information(self, "Success", f"Invoice saved at:\n{filename}")
            except Exception as e:
                QMessageBox.critical(self, "Error", f"Failed to generate PDF:\n{e}")

    def _create_invoice_pdf(self, filepath: str, gst_result: GSTResult, amount: float, gst_rate: float):
        # Defensive: If reportlab import failed, raise error
        if 'canvas' not in globals():
            raise ImportError("reportlab module is required to generate invoice PDF.")

        # Use ReportLab to create PDF invoice
        c = canvas.Canvas(filepath, pagesize=A4)
        width, height = A4

        margin = 20 * mm
        usable_width = width - 2 * margin

        # Title
        c.setFont("Helvetica-Bold", 20)
        c.setFillColor(COLOR_INDIGO)
        c.drawString(margin, height - margin - 30, "GST Invoice")

        # Date
        c.setFont("Helvetica", 10)
        c.setFillColor(COLOR_DARKGRAY)
        c.drawRightString(width - margin, height - margin - 20, f"Date: {datetime.now().strftime('%d-%b-%Y')}")

        # Seller Info (Developer branding)
        c.setFont("Helvetica-Bold", 12)
        c.setFillColor(COLOR_TEAL)
        c.drawString(margin, height - margin - 70, "Seller - Harsh Computronics")
        c.setFont("Helvetica", 10)
        c.setFillColor(COLOR_BLACK)
        c.drawString(margin, height - margin - 85, "Email: <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>")
        c.drawString(margin, height - margin - 100, "Website: hcomputronics.com")

        # Horizontal line
        c.setStrokeColor(COLOR_TEAL)
        c.setLineWidth(1)
        c.line(margin, height - margin - 110, width - margin, height - margin - 110)

        start_y = height - margin - 130
        line_height = 18

        # Amount and GST Details
        c.setFont("Helvetica-Bold", 12)
        c.drawString(margin, start_y, "Details:")
        c.setFont("Helvetica", 10)
        c.drawString(margin + 20, start_y - line_height * 1, f"Amount (₹): {amount:,.2f}")
        c.drawString(margin + 20, start_y - line_height * 2, f"GST Rate (%): {gst_rate:,.2f}")
        c.drawString(margin + 20, start_y - line_height * 3, f"CGST (₹): {gst_result.cgst:,.2f}")
        c.drawString(margin + 20, start_y - line_height * 4, f"SGST (₹): {gst_result.sgst:,.2f}")
        c.drawString(margin + 20, start_y - line_height * 5, f"Total Amount (₹): {gst_result.total:,.2f}")

        # Footer (branding)
        footer_text = "Generated by Harsh Computronics | hcomputronics.com"
        c.setFont("Helvetica-Oblique", 8)
        c.setFillColor(COLOR_LIGHTGRAY)
        c.drawCentredString(width / 2, margin / 2, footer_text)

        c.showPage()
        c.save()

# ========== Ad Banner Rotator Widget ==========

class AdBannerRotator(QWidget):
    """
    Widget that rotates ad banners within a fixed area
    """

    def __init__(self, pixmaps: list[QPixmap], rotation_interval_ms=5000, parent=None):
        super().__init__(parent)
        self.pixmaps = pixmaps
        self.index = 0
        self.rotation_interval_ms = rotation_interval_ms
        self.setup_ui()
        self.start_rotation()

    def setup_ui(self):
        self.setFixedHeight(120)
        self.setMinimumWidth(300)
        self.label = QLabel(self)
        self.label.setScaledContents(True)
        self.label.setFixedSize(300, 120)
        self.label.setAlignment(Qt.AlignmentFlag.AlignCenter)

        self.label.setPixmap(self.pixmaps[self.index])

        # Border and shadow for nice effect
        self.setStyleSheet(f"""
            background-color: {COLOR_LIGHTGRAY};
            border-radius: 8px;
        """)
        # Drop shadow effect
        shadow = QGraphicsDropShadowEffect(self)
        shadow.setBlurRadius(8)
        shadow.setOffset(2, 2)
        shadow.setColor(QColor(50, 50, 50, 120))
        self.setGraphicsEffect(shadow)

    def start_rotation(self):
        self.timer = QTimer(self)
        self.timer.timeout.connect(self.rotate_banner)
        self.timer.start(self.rotation_interval_ms)

    def rotate_banner(self):
        old_pixmap = self.pixmaps[self.index]
        self.index = (self.index + 1) % len(self.pixmaps)
        new_pixmap = self.pixmaps[self.index]

        # Fade animation
        self._animate_fade(old_pixmap, new_pixmap)

    def _animate_fade(self, old_pixmap: QPixmap, new_pixmap: QPixmap):
        from PyQt6.QtWidgets import QGraphicsOpacityEffect

        self.opacity_effect = QGraphicsOpacityEffect(self.label)
        self.label.setGraphicsEffect(self.opacity_effect)

        duration = 700

        anim = QPropertyAnimation(self.opacity_effect, b"opacity", self)
        anim.setDuration(duration)
        anim.setStartValue(1.0)
        anim.setEndValue(0.0)
        anim.setEasingCurve(QEasingCurve.Type.InOutQuad)

        def on_fade_out_finished():
            self.label.setPixmap(new_pixmap)
            anim2 = QPropertyAnimation(self.opacity_effect, b"opacity", self)
            anim2.setDuration(duration)
            anim2.setStartValue(0.0)
            anim2.setEndValue(1.0)
            anim2.setEasingCurve(QEasingCurve.Type.InOutQuad)
            anim2.start()
            self.anim2 = anim2  # keep reference

        anim.finished.connect(on_fade_out_finished)
        anim.start()
        self.anim = anim  # prevent GC


# ========== Settings Widget with Developer Branding ==========

class SettingsWidget(QWidget):
    """
    Settings and Developer info panel
    """

    def __init__(self, parent=None):
        super().__init__(parent)
        self.setup_ui()

    def setup_ui(self):
        layout = QVBoxLayout(self)
        layout.setContentsMargins(36, 24, 36, 24)
        layout.setSpacing(12)

        title = QLabel("Settings & Info")
        title.setFont(QFont("Roboto", 16, QFont.Weight.Bold))
        title.setStyleSheet(f"color: {COLOR_INDIGO}")
        layout.addWidget(title)

        # Ad-Free Upgrade Message
        upgrade_label = QLabel()
        upgrade_label.setText(
            "<b>Upgrade to Ad-Free Version</b><br>"
            "Enjoy uninterrupted experience by purchasing the ad-free upgrade.<br>"
            "<i>Contact <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS> for details.</i>"
        )
        upgrade_label.setWordWrap(True)
        upgrade_label.setFont(QFont("Roboto", 12))
        upgrade_label.setStyleSheet(f"color: {COLOR_DARKGRAY}")
        layout.addWidget(upgrade_label)

        # Spacer
        layout.addStretch()

        # Developer Branding
        dev_title = QLabel("Developer")
        dev_title.setFont(QFont("Roboto", 14, QFont.Weight.Bold))
        dev_title.setStyleSheet(f"color: {COLOR_TEAL}")
        layout.addWidget(dev_title)

        dev_name = QLabel("Harsh Computronics")
        dev_name.setFont(QFont("Roboto", 12))
        dev_email = QLabel('<a href="mailto:<PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>"><PRESIDIO_ANONYMIZED_EMAIL_ADDRESS></a>')
        dev_email.setFont(QFont("Roboto", 12))
        dev_email.setOpenExternalLinks(True)
        dev_website = QLabel('<a href="http://hcomputronics.com" target="_blank">hcomputronics.com</a>')
        dev_website.setFont(QFont("Roboto", 12))
        dev_website.setOpenExternalLinks(True)

        for w in (dev_name, dev_email, dev_website):
            w.setStyleSheet(f"color: {COLOR_DARKGRAY}")
            layout.addWidget(w)


# ========== Main Application Window ==========

class MainWindow(QWidget):
    """
    Main application window with tabs, ads, and footer branding.
    """

    def __init__(self):
        super().__init__()
        self.setWindowTitle("GST Calculator - Harsh Computronics")
        self.setMinimumSize(800, 600)
        self.setWindowIcon(ICON_CALCULATE)
        self.setup_ui()
        self.apply_styles()
        self.setAttribute(Qt.WidgetAttribute.WA_StyledBackground)

    def setup_ui(self):
        # Root layout
        root_layout = QVBoxLayout(self)
        root_layout.setContentsMargins(0, 0, 0, 0)
        root_layout.setSpacing(0)

        # Content area with tabs and sidebar
        content_layout = QHBoxLayout()
        content_layout.setContentsMargins(36, 36, 36, 0)
        content_layout.setSpacing(24)

        # Left Side: Tabs
        self.tabs = QTabWidget()
        self.tabs.setTabPosition(QTabWidget.TabPosition.North)
        self.tabs.setMovable(False)
        self.tabs.setUsesScrollButtons(False)

        # Main calculator tab
        self.gst_calc_widget = GSTCalculatorWidget()
        self.tabs.addTab(self.gst_calc_widget, ICON_CALCULATE, "Calculator")

        # Settings tab
        self.settings_widget = SettingsWidget()
        self.tabs.addTab(self.settings_widget, ICON_SETTINGS, "Settings")

        # Customize tab bar (hover effect)
        self._customize_tab_bar()

        content_layout.addWidget(self.tabs, stretch=3)

        # Right Side: Ad Panel
        self.ad_rotator = AdBannerRotator(AD_BANNER_PIXMAPS)
        content_layout.addWidget(self.ad_rotator, stretch=1)

        root_layout.addLayout(content_layout)

        # Footer branding at bottom
        footer = QWidget()
        footer_layout = QHBoxLayout(footer)
        footer_layout.setContentsMargins(36, 12, 36, 12)
        footer_layout.setSpacing(6)

        footer_label = QLabel("© 2024 Harsh Computronics | hcomputronics.com | <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>")
        footer_label.setFont(QFont("Roboto", 9))
        footer_label.setStyleSheet(f"color: {COLOR_DARKGRAY}")

        footer_layout.addWidget(footer_label)
        root_layout.addWidget(footer)

        apply_fonts(QApplication.instance())

    def _customize_tab_bar(self):
        # Style sheet with hover effect for tabs
        self.tabs.setStyleSheet(f"""
        QTabBar::tab {{
            background: {COLOR_LIGHTGRAY};
            color: {COLOR_INDIGO};
            font-weight: 600;
            padding: 10px 24px;
            border-top-left-radius: 6px;
            border-top-right-radius: 6px;
            margin-right: 12px;
            min-width: 120px;
            transition: background-color 0.3s ease;
        }}

        QTabBar::tab:hover {{
            background: {COLOR_TEAL};
            color: {COLOR_WHITE};
        }}

        QTabBar::tab:selected {{
            background: {COLOR_INDIGO};
            color: {COLOR_WHITE};
        }}

        QTabWidget::pane {{
            border: 1px solid {COLOR_LIGHTGRAY};
            border-top: none;
            background: {COLOR_WHITE};
            border-bottom-left-radius: 12px;
            border-bottom-right-radius: 12px;
        }}
        """)

    def apply_styles(self):
        self.setStyleSheet(f"""
        QWidget {{
            background-color: {COLOR_LIGHTGRAY};
        }}
        """)


# ========== Main Entrypoint ==========

def main():
    app = QApplication(sys.argv)
    # High DPI scaling for better display on modern screens
    QApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)

    window = MainWindow()
    window.show()

    sys.exit(app.exec())


if __name__ == "__main__":
    main()"

solve whole code for error glitch bugs warnings, and give whole working code back