Skip to content

UI Components

biopro_sdk.plugin.components

Semantic UI components for BioPro SDK.

Provides pre-styled button and component classes that respect the active theme and maintain visual consistency across all plugins.

BioButton

Bases: QPushButton

Base unified button class.

Variants: 'primary', 'secondary', 'danger'.

Source code in src/biopro_sdk/plugin/components.py
class BioButton(QPushButton):
    """Base unified button class.

    Variants: 'primary', 'secondary', 'danger'.
    """

    def __init__(self, text: str, variant: str = "primary", parent=None):
        super().__init__(text, parent)
        self.setObjectName(f"BioButton_{variant}")
        self.variant = variant
        self.setCursor(Qt.CursorShape.PointingHandCursor)
        self._glow_effect = None
        self.custom_css_overrides = ""
        _connect_theme_signal(self._apply_theme_styles)

    def _apply_theme_styles(self) -> None:
        self.setProperty("variant", self.variant)
        self.style().unpolish(self)
        self.style().polish(self)

        if self.custom_css_overrides:
            self.setStyleSheet(f"QPushButton {{ {self.custom_css_overrides} }}")
        else:
            self.setStyleSheet("")

        if self.variant == "primary" and Colors.GLOW_COLOR != "transparent":
            from PyQt6.QtGui import QColor
            from PyQt6.QtWidgets import QGraphicsDropShadowEffect

            if self._glow_effect is None:
                self._glow_effect = QGraphicsDropShadowEffect(self)
                self.setGraphicsEffect(self._glow_effect)

            if self._glow_effect is not None:
                self._glow_effect.setBlurRadius(15)
                self._glow_effect.setOffset(0, 0)
                self._glow_effect.setColor(QColor(Colors.GLOW_COLOR))
        else:
            if self._glow_effect:
                self.setGraphicsEffect(None)
                self._glow_effect = None

BioCancelButton

Bases: SecondaryButton

Pre-configured action button for cancelling tasks.

Source code in src/biopro_sdk/plugin/components.py
class BioCancelButton(SecondaryButton):
    """Pre-configured action button for cancelling tasks."""

    def __init__(self, text: str = "⏹ Cancel", parent=None):
        super().__init__(text, parent)

BioCaptionLabel

Bases: QLabel

For educational text or hints.

Source code in src/biopro_sdk/plugin/components.py
class BioCaptionLabel(QLabel):
    """For educational text or hints."""

    def __init__(self, text: str, parent=None):
        super().__init__(text, parent)
        self.setWordWrap(True)
        _connect_theme_signal(self._apply_theme_styles)

    def _apply_theme_styles(self) -> None:
        try:
            size = getattr(Fonts, "SIZE_SMALL", 11)
        except AttributeError:
            size = 11
        self.setStyleSheet(f"font-size: {size}px; color: {Colors.FG_SECONDARY};")

BioComboBox

Bases: QComboBox

Standardized combo box.

Source code in src/biopro_sdk/plugin/components.py
class BioComboBox(QComboBox):
    """Standardized combo box."""

    def __init__(self, parent=None):
        super().__init__(parent)
        from PyQt6.QtWidgets import QListView

        # Override native macOS popup view to allow proper styling
        view = QListView()
        self.setView(view)
        self.setItemDelegate(QStyledItemDelegate(self))
        _connect_theme_signal(self._apply_theme_styles)

    def _apply_theme_styles(self) -> None:
        self.setStyleSheet(f"""
            QComboBox {{
                combobox-popup: 0;
                background-color: {Colors.BG_MEDIUM};
                color: {Colors.FG_PRIMARY};
                border: 1px solid {Colors.BORDER};
                border-radius: 4px;
                padding: 4px 8px;
            }}
            QComboBox::drop-down {{
                border-left: 1px solid {Colors.BORDER};
            }}
            QComboBox QAbstractItemView {{
                background-color: {Colors.BG_MEDIUM};
                color: {Colors.FG_PRIMARY};
                selection-background-color: {Colors.ACCENT_PRIMARY};
                selection-color: {Colors.BG_DARKEST};
                border: 1px solid {Colors.BORDER};
                border-radius: 4px;
                outline: none;
                padding: 2px;
            }}
            QComboBox QAbstractItemView::item {{
                min-height: 24px;
                padding: 2px 4px;
                border-radius: 2px;
            }}
            QComboBox QAbstractItemView::item:hover {{
                background-color: {Colors.BG_LIGHT};
            }}
            QComboBox QAbstractItemView::item:selected {{
                background-color: {Colors.ACCENT_PRIMARY};
                color: {Colors.BG_DARKEST};
            }}
        """)

BioDoubleSpinBox

Bases: QDoubleSpinBox

Standardized floating point input.

Source code in src/biopro_sdk/plugin/components.py
class BioDoubleSpinBox(QDoubleSpinBox):
    """Standardized floating point input."""

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

    def _apply_theme_styles(self) -> None:
        self.setStyleSheet(f"""
            QDoubleSpinBox {{
                background-color: {Colors.BG_MEDIUM};
                color: {Colors.FG_PRIMARY};
                border: 1px solid {Colors.BORDER};
                border-radius: 4px;
                padding: 4px 8px;
            }}
        """)

BioHelpButton

Bases: QPushButton

Small help (?) button that shows a rich popup dialog on click.

Source code in src/biopro_sdk/plugin/components.py
class BioHelpButton(QPushButton):
    """Small help (?) button that shows a rich popup dialog on click."""

    def __init__(self, parent=None):
        super().__init__("?", parent)
        self.setObjectName("BioHelpButton")
        self.setCursor(Qt.CursorShape.PointingHandCursor)
        self.setFixedSize(20, 20)
        self._help_text = ""
        self._help_title = ""
        self.clicked.connect(self._show_popup)
        _connect_theme_signal(self._apply_theme_styles)

    def setHelpText(self, text: str, title: str = "") -> None:
        """Set the detailed help text and optional title for the popup."""
        self._help_text = text
        self._help_title = title

    def setToolTip(self, text: str | None) -> None:
        """Override to use the click popup instead of the native hover tooltip for backwards compatibility."""
        super().setToolTip("")
        self.setHelpText(text or "")

    def _show_popup(self) -> None:
        if not self._help_text:
            return

        self._popup = _HelpPopup(self._help_text, self._help_title, self.window())
        self._popup.adjustSize()

        # Position the popup below the button
        pos = self.mapToGlobal(self.rect().bottomLeft())
        # Offset slightly for aesthetics
        pos.setY(pos.y() + 5)
        pos.setX(pos.x() - 10)
        self._popup.move(pos)
        self._popup.show()

    def _apply_theme_styles(self) -> None:
        self.setStyleSheet(f"""
            QPushButton#BioHelpButton {{
                background-color: transparent;
                color: {Colors.FG_SECONDARY};
                border: 1px solid {Colors.BORDER};
                border-radius: 10px;
                font-size: 11px;
                font-weight: bold;
                font-family: {Fonts.FAMILY_UI};
                padding: 0px;
                margin: 0px;
            }}
            QPushButton#BioHelpButton:hover {{
                background-color: {Colors.BG_LIGHT};
                color: {Colors.FG_PRIMARY};
                border-color: {Colors.FG_PRIMARY};
            }}
        """)

setHelpText(text, title='')

Set the detailed help text and optional title for the popup.

Source code in src/biopro_sdk/plugin/components.py
def setHelpText(self, text: str, title: str = "") -> None:
    """Set the detailed help text and optional title for the popup."""
    self._help_text = text
    self._help_title = title

setToolTip(text)

Override to use the click popup instead of the native hover tooltip for backwards compatibility.

Source code in src/biopro_sdk/plugin/components.py
def setToolTip(self, text: str | None) -> None:
    """Override to use the click popup instead of the native hover tooltip for backwards compatibility."""
    super().setToolTip("")
    self.setHelpText(text or "")

BioLineEdit

Bases: QLineEdit

Standardized text input.

Source code in src/biopro_sdk/plugin/components.py
class BioLineEdit(QLineEdit):
    """Standardized text input."""

    def __init__(self, text: str = "", parent=None):
        super().__init__(text, parent)
        _connect_theme_signal(self._apply_theme_styles)

    def _apply_theme_styles(self) -> None:
        self.setStyleSheet(f"""
            QLineEdit {{
                background-color: {Colors.BG_MEDIUM};
                color: {Colors.FG_PRIMARY};
                border: 1px solid {Colors.BORDER};
                border-radius: 4px;
                padding: 4px 8px;
            }}
        """)

BioListWidget

Bases: QListWidget

Standardized list widget.

Source code in src/biopro_sdk/plugin/components.py
class BioListWidget(QListWidget):
    """Standardized list widget."""

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

    def _apply_theme_styles(self) -> None:
        self.setStyleSheet(f"""
            QListWidget {{
                background-color: transparent;
                color: {Colors.FG_PRIMARY};
                border: 1px solid {Colors.BORDER};
                border-radius: 4px;
            }}
            QListWidget::item:selected {{
                background-color: {Colors.ACCENT_PRIMARY};
                color: {Colors.BG_DARKEST};
            }}
        """)

BioRunButton

Bases: PrimaryButton

Pre-configured action button for starting tasks.

Source code in src/biopro_sdk/plugin/components.py
class BioRunButton(PrimaryButton):
    """Pre-configured action button for starting tasks."""

    def __init__(self, text: str = "🧬 Run", parent=None):
        super().__init__(text, parent)

BioScrollArea

Bases: QScrollArea

Standardized scroll area with transparent background.

Source code in src/biopro_sdk/plugin/components.py
class BioScrollArea(QScrollArea):
    """Standardized scroll area with transparent background."""

    def __init__(self, parent=None):
        super().__init__(parent)
        self.setWidgetResizable(True)
        _connect_theme_signal(self._apply_theme_styles)

    def _apply_theme_styles(self) -> None:
        self.setStyleSheet("""
            QScrollArea {
                background-color: transparent;
                border: none;
            }
        """)

BioSpinBox

Bases: QSpinBox

Standardized numeric input.

Source code in src/biopro_sdk/plugin/components.py
class BioSpinBox(QSpinBox):
    """Standardized numeric input."""

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

    def _apply_theme_styles(self) -> None:
        self.setStyleSheet(f"""
            QSpinBox {{
                background-color: {Colors.BG_MEDIUM};
                color: {Colors.FG_PRIMARY};
                border: 1px solid {Colors.BORDER};
                border-radius: 4px;
                padding: 4px 8px;
            }}
        """)

BioSplitter

Bases: QSplitter

Standardized splitter.

Source code in src/biopro_sdk/plugin/components.py
class BioSplitter(QSplitter):
    """Standardized splitter."""

    def __init__(self, orientation=Qt.Orientation.Horizontal, parent=None):
        super().__init__(orientation, parent)
        _connect_theme_signal(self._apply_theme_styles)

    def _apply_theme_styles(self) -> None:
        self.setStyleSheet(f"""
            QSplitter::handle {{
                background-color: {Colors.BORDER};
            }}
        """)

BioStatusLabel

Bases: QLabel

Standardized italicized status text.

Source code in src/biopro_sdk/plugin/components.py
class BioStatusLabel(QLabel):
    """Standardized italicized status text."""

    def __init__(self, text: str, parent=None):
        super().__init__(text, parent)
        self.setWordWrap(True)
        _connect_theme_signal(self._apply_theme_styles)

    def _apply_theme_styles(self) -> None:
        self.setStyleSheet(f"font-size: {Fonts.SIZE_NORMAL}px; font-style: italic; color: {Colors.FG_SECONDARY};")

BioTableWidget

Bases: QTableWidget

Standardized table widget.

Source code in src/biopro_sdk/plugin/components.py
class BioTableWidget(QTableWidget):
    """Standardized table widget."""

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

    def _apply_theme_styles(self) -> None:
        self.setStyleSheet(f"""
            QTableWidget {{
                background-color: transparent;
                color: {Colors.FG_PRIMARY};
                border: 1px solid {Colors.BORDER};
                gridline-color: {Colors.BORDER};
            }}
            QHeaderView::section {{
                background-color: {Colors.BG_MEDIUM};
                color: {Colors.FG_PRIMARY};
                border: 1px solid {Colors.BORDER};
            }}
            QTableWidget::item:selected {{
                background-color: {Colors.ACCENT_PRIMARY};
                color: {Colors.BG_DARKEST};
            }}
        """)

BioToggleButton

Bases: QPushButton

A button that handles active/inactive state natively.

Source code in src/biopro_sdk/plugin/components.py
class BioToggleButton(QPushButton):
    """A button that handles active/inactive state natively."""

    def __init__(self, text: str, parent=None):
        super().__init__(text, parent)
        self.setObjectName("BioToggleButton")
        self.setCheckable(True)
        self.setCursor(Qt.CursorShape.PointingHandCursor)

        # Extensible defaults that subclasses or instances can configure
        self.custom_css_overrides = ""

        _connect_theme_signal(self._apply_theme_styles)

    def _apply_theme_styles(self) -> None:
        self.style().unpolish(self)
        self.style().polish(self)

        if self.custom_css_overrides:
            self.setStyleSheet(f"QPushButton#BioToggleButton {{ {self.custom_css_overrides} }}")
        else:
            self.setStyleSheet("")

DangerButton

Bases: BioButton

Destructive action button for delete/remove operations (backwards compatible).

Source code in src/biopro_sdk/plugin/components.py
class DangerButton(BioButton):
    """Destructive action button for delete/remove operations (backwards compatible)."""

    def __init__(self, text: str, parent=None):
        super().__init__(text, variant="danger", parent=parent)

HeaderLabel

Bases: QLabel

Standardized H1 header label.

Source code in src/biopro_sdk/plugin/components.py
class HeaderLabel(QLabel):
    """Standardized H1 header label."""

    def __init__(self, text: str, parent=None):
        super().__init__(text, parent)
        self.setWordWrap(True)
        _connect_theme_signal(self._apply_theme_styles)

    def _apply_theme_styles(self) -> None:
        self.setStyleSheet(
            f"font-size: {Fonts.SIZE_LARGE}px; "
            f"font-weight: bold; "
            f"font-family: {Fonts.FAMILY_HEADINGS}; "
            f"color: {Colors.FG_PRIMARY};"
        )

ModuleCard

Bases: QFrame

Standardized, interactive card for lists and grids.

Source code in src/biopro_sdk/plugin/components.py
class ModuleCard(QFrame):
    """Standardized, interactive card for lists and grids."""

    def __init__(self, parent=None):
        super().__init__(parent)
        self.setObjectName("BioCard")
        _connect_theme_signal(self._apply_theme_styles)

    def _apply_theme_styles(self) -> None:
        glow_css = ""
        if Colors.GLOW_COLOR != "transparent":
            glow_css = f"border: 1px solid {Colors.ACCENT_PRIMARY};"

        self.setStyleSheet(f"""
            QFrame#BioCard {{
                background-color: {Colors.BG_DARK};
                border: 1px solid {Colors.BORDER};
                border-radius: 10px;
                font-family: {Fonts.FAMILY_UI};
            }}
            QFrame#BioCard:hover {{
                border: 1px solid {Colors.ACCENT_PRIMARY};
                background-color: {Colors.BG_MEDIUM};
                {glow_css}
            }}
        """)

PrimaryButton

Bases: BioButton

Primary action button using accent color (backwards compatible).

Source code in src/biopro_sdk/plugin/components.py
class PrimaryButton(BioButton):
    """Primary action button using accent color (backwards compatible)."""

    def __init__(self, text: str, parent=None):
        super().__init__(text, variant="primary", parent=parent)

SecondaryButton

Bases: BioButton

Secondary/outline button for non-critical actions (backwards compatible).

Source code in src/biopro_sdk/plugin/components.py
class SecondaryButton(BioButton):
    """Secondary/outline button for non-critical actions (backwards compatible)."""

    def __init__(self, text: str, parent=None):
        super().__init__(text, variant="secondary", parent=parent)

SubtitleLabel

Bases: QLabel

Standardized subtitle/secondary header label.

Source code in src/biopro_sdk/plugin/components.py
class SubtitleLabel(QLabel):
    """Standardized subtitle/secondary header label."""

    def __init__(self, text: str, parent=None):
        super().__init__(text, parent)
        self.setWordWrap(True)
        _connect_theme_signal(self._apply_theme_styles)

    def _apply_theme_styles(self) -> None:
        self.setStyleSheet(f"font-size: {Fonts.SIZE_NORMAL}px; font-weight: 600; color: {Colors.FG_PRIMARY};")

apply_component_style(widget, component_type)

Helper function to dynamically apply theme CSS without requiring a subclass.

Source code in src/biopro_sdk/plugin/components.py
def apply_component_style(widget: QWidget, component_type: str) -> None:
    """Helper function to dynamically apply theme CSS without requiring a subclass."""
    # Useful for injecting basic styles into standard Qt widgets directly
    pass