Collapsible Widget¶
The collapsible widget provides a single expandable/collapsible section with a header and content area.
Preview
FXCollapsibleWidget
¶
Bases: ,
A widget that can expand or collapse its content.
The widget consists of a header with a toggle button and a content area that can be shown or hidden with an animation effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
|
Parent widget. |
None
|
|
|
Title displayed in the header. |
''
|
|
|
Duration of expand/collapse animation in ms. |
150
|
|
|
Maximum height for content area when expanded (0 = no limit). |
300
|
|
|
Optional icon to display before the title. Can be a QIcon, an icon name string (for fxicons), or None. |
None
|
Examples:
>>> from qtpy.QtWidgets import QLabel, QVBoxLayout
>>> collapsible = FXCollapsibleWidget(title="Settings")
>>> layout = QVBoxLayout()
>>> layout.addWidget(QLabel("Option 1"))
>>> layout.addWidget(QLabel("Option 2"))
>>> collapsible.set_content_layout(layout)
>>>
>>> # With an icon
>>> collapsible_with_icon = FXCollapsibleWidget(
... title="Settings",
... title_icon="settings"
... )
Methods:
| Name | Description |
|---|---|
|
Initialize the collapsible section. |
|
Get the current title text. |
|
Get the current title icon. |
|
Set the layout for the content area. |
|
Set the title text. |
|
Set an icon to display before the title. |
__init__
¶
__init__(
parent : Optional [QWidget ] = None,
title : str = "",
animation_duration : int = 150,
max_content_height : int = 300,
title_icon : Optional [Union [QIcon , str ]] = None,
)
Initialize the collapsible section.
get_title
¶
Get the current title text.
Returns:
| Type | Description |
|---|---|
|
The current title text. |
get_title_icon
¶
Get the current title icon.
Returns:
| Type | Description |
|---|---|
|
The current title icon, or None if no icon is set. |
set_content_layout
¶
Set the layout for the content area.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
|
The layout to set for the content area. |
required |
set_title
¶
Set the title text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
|
The title text to display. |
required |