Skip to content

Collapsible Panel

app.ui.qt.widgets.collapsible_panel

View source code

Module for collapsible panel; implements the Qt presentation components.

See Also

Layer: Presentation. Context: Implements the qt presentation components at this architectural boundary.

CollapsiblePanel

Bases: QWidget

A custom widget that provides a collapsible panel. Clicking the toggle button shows/hides the child widgets.

PARAMETER DESCRIPTION
title

Text displayed in the panel's header.

TYPE: str

parent

Optional Qt parent object.

TYPE: QWidget | None DEFAULT: None

content_area: QWidget = QWidget() instance-attribute

content_layout: QVBoxLayout = create_vbox_layout(self.content_area, margins=(4, 1, 4, 2), spacing=2) instance-attribute

is_expanded: bool = True instance-attribute

toggle_button = QPushButton(f'▼ {self._title}') instance-attribute

__init__(title: str, parent: QWidget | None = None) -> None

add_layout(layout: QVBoxLayout | QHBoxLayout) -> None

Append a nested layout to the panel's content layout.

PARAMETER DESCRIPTION
layout

Layout to place in the collapsible content area.

TYPE: QVBoxLayout | QHBoxLayout

add_widget(widget: QWidget) -> None

Append a widget to the panel's content layout.

PARAMETER DESCRIPTION
widget

Widget to place in the collapsible content area.

TYPE: QWidget

toggle() -> None

Invert the expanded state and update the content visibility and header icon.