Skip to content

banner_widget

A banner widget with CAREamics logo, and links to Github and documentation.

CAREamicsBanner #

Bases: QWidget

Banner widget with CAREamics logo, and links to Github and documentation.

Parameters:

Name Type Description Default
title str

Title of the banner.

required
short_desc str

Short description of the banner.

required
Source code in src/careamics_napari/widgets/banner_widget.py
class CAREamicsBanner(QWidget):
    """Banner widget with CAREamics logo, and links to Github and documentation.

    Parameters
    ----------
    title : str
        Title of the banner.
    short_desc : str
        Short description of the banner.
    """

    def __init__(
        self: Self,
        title: str,
        short_desc: str,
    ) -> None:
        """Initialize the widget.

        Parameters
        ----------
        title : str
            Title of the banner.
        short_desc : str
            Short description of the banner.
        """
        super().__init__()

        self.setMinimumSize(250, 200)

        layout = QHBoxLayout()
        # layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)

        # bg_color = self.palette().color(QtGui.QPalette.ColorRole.Background).name()

        # logo
        icon = QPixmap(ICON_CAREAMICS)
        img_widget = QLabel()
        img_widget.setPixmap(icon)
        img_widget.setFixedSize(94, 128)

        # right panel
        right_layout = QVBoxLayout()
        right_widget = QWidget()
        right_widget.setLayout(right_layout)

        # title
        title_label = QLabel(title)
        title_label.setStyleSheet("font-weight: bold;")

        # description
        description_widget = QPlainTextEdit()
        description_widget.setReadOnly(True)
        description_widget.setPlainText(short_desc)
        description_widget.setFixedSize(200, 50)
        # description_widget.setStyleSheet(
        #     f"background-color: {bg_color};"
        #     f"border: 2px solid {bg_color};"
        # )

        # bottom widget
        bottom_widget = QWidget()
        bottom_widget.setLayout(QHBoxLayout())

        # github logo
        gh_icon = QPixmap(ICON_GITHUB)
        gh_widget = QLabel()
        gh_widget.setPixmap(gh_icon)
        gh_widget.mousePressEvent = _open_link(GH_LINK)
        gh_widget.setCursor(QCursor(QtCore.Qt.CursorShape.PointingHandCursor))
        gh_widget.setToolTip("Report issues")

        # add widgets
        bottom_widget.layout().addWidget(_create_link(DOC_LINK, "Documentation"))
        bottom_widget.layout().addWidget(gh_widget)

        right_widget.layout().addWidget(title_label)
        right_widget.layout().addWidget(description_widget)
        right_widget.layout().addWidget(bottom_widget)

        # add widgets
        layout.addWidget(img_widget)
        layout.addWidget(right_widget)

__init__(title, short_desc) #

Initialize the widget.

Parameters:

Name Type Description Default
title str

Title of the banner.

required
short_desc str

Short description of the banner.

required
Source code in src/careamics_napari/widgets/banner_widget.py
def __init__(
    self: Self,
    title: str,
    short_desc: str,
) -> None:
    """Initialize the widget.

    Parameters
    ----------
    title : str
        Title of the banner.
    short_desc : str
        Short description of the banner.
    """
    super().__init__()

    self.setMinimumSize(250, 200)

    layout = QHBoxLayout()
    # layout.setContentsMargins(0, 0, 0, 0)
    self.setLayout(layout)

    # bg_color = self.palette().color(QtGui.QPalette.ColorRole.Background).name()

    # logo
    icon = QPixmap(ICON_CAREAMICS)
    img_widget = QLabel()
    img_widget.setPixmap(icon)
    img_widget.setFixedSize(94, 128)

    # right panel
    right_layout = QVBoxLayout()
    right_widget = QWidget()
    right_widget.setLayout(right_layout)

    # title
    title_label = QLabel(title)
    title_label.setStyleSheet("font-weight: bold;")

    # description
    description_widget = QPlainTextEdit()
    description_widget.setReadOnly(True)
    description_widget.setPlainText(short_desc)
    description_widget.setFixedSize(200, 50)
    # description_widget.setStyleSheet(
    #     f"background-color: {bg_color};"
    #     f"border: 2px solid {bg_color};"
    # )

    # bottom widget
    bottom_widget = QWidget()
    bottom_widget.setLayout(QHBoxLayout())

    # github logo
    gh_icon = QPixmap(ICON_GITHUB)
    gh_widget = QLabel()
    gh_widget.setPixmap(gh_icon)
    gh_widget.mousePressEvent = _open_link(GH_LINK)
    gh_widget.setCursor(QCursor(QtCore.Qt.CursorShape.PointingHandCursor))
    gh_widget.setToolTip("Report issues")

    # add widgets
    bottom_widget.layout().addWidget(_create_link(DOC_LINK, "Documentation"))
    bottom_widget.layout().addWidget(gh_widget)

    right_widget.layout().addWidget(title_label)
    right_widget.layout().addWidget(description_widget)
    right_widget.layout().addWidget(bottom_widget)

    # add widgets
    layout.addWidget(img_widget)
    layout.addWidget(right_widget)