collapsible
_collapsible
¶
Collapsible widget implementation.
Classes:
| Name | Description |
|---|---|
FXCollapsibleWidget |
A widget that can expand or collapse its content. |
Classes¶
FXCollapsibleWidget
¶
FXCollapsibleWidget(
parent: Optional[QWidget] = None,
title: str = "",
icon: Optional[Union[QIcon, str]] = None,
animation_duration: int = 150,
max_content_height: int = 300,
)
Bases: FXThemeAware, QWidget
flowchart TD
fxgui.fxwidgets._collapsible.FXCollapsibleWidget[FXCollapsibleWidget]
fxgui.fxstyle.FXThemeAware[FXThemeAware]
fxgui.fxstyle.FXThemeAware --> fxgui.fxwidgets._collapsible.FXCollapsibleWidget
click fxgui.fxwidgets._collapsible.FXCollapsibleWidget href "" "fxgui.fxwidgets._collapsible.FXCollapsibleWidget"
click fxgui.fxstyle.FXThemeAware href "" "fxgui.fxstyle.FXThemeAware"
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 |
|---|---|---|---|
|
Optional[QWidget]
|
Parent widget. |
None
|
|
str
|
Title displayed in the header. |
''
|
|
Optional[Union[QIcon, str]]
|
Optional icon to display before the title. Can be a QIcon, an icon name string (for fxicons), or None. |
None
|
|
int
|
Duration of expand/collapse animation in ms. |
150
|
|
int
|
Maximum height for content area when expanded (0 = no limit). |
300
|
Signals
expanded: Emitted when the widget is expanded. collapsed: Emitted when the widget is collapsed.
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",
... icon="settings"
... )
Initialize the collapsible section.
Methods:
| Name | Description |
|---|---|
collapse |
Collapse the widget to hide content. |
expand |
Expand the widget to show content. |
get_icon |
Get the current icon. |
get_title |
Get the current title text. |
get_title_icon |
Get the title icon (deprecated, use get_icon). |
set_content_layout |
Set the layout for the content area. |
set_content_widget |
Set the content widget directly. |
set_icon |
Set an icon to display before the title. |
set_title |
Set the title text. |
set_title_icon |
Set the title icon (deprecated, use set_icon). |
toggle |
Toggle the expanded/collapsed state. |
Attributes:
| Name | Type | Description |
|---|---|---|
animation_duration |
int
|
Return the animation duration in milliseconds. |
content_area |
QScrollArea
|
Return the content area (deprecated, use _content_area). |
header_widget |
QFrame
|
Return the header widget (deprecated, use _header). |
is_expanded |
bool
|
Return whether the widget is expanded. |
max_content_height |
int
|
Return the maximum content height. |
title |
str
|
Return the title text. |
title_icon_label |
QLabel
|
Return the icon label (deprecated, use _icon_label). |
title_label |
QLabel
|
Return the title label (deprecated, use _title_label). |
toggle_button |
QToolButton
|
Return the toggle button (deprecated, use _toggle_btn). |
Attributes¶
animation_duration
property
writable
¶
animation_duration: int
Return the animation duration in milliseconds.
content_area
property
¶
Return the content area (deprecated, use _content_area).
title_icon_label
property
¶
Return the icon label (deprecated, use _icon_label).
toggle_button
property
¶
Return the toggle button (deprecated, use _toggle_btn).
Functions¶
collapse
¶
expand
¶
get_icon
¶
get_icon() -> Optional[QIcon]
Get the current icon.
Returns:
| Type | Description |
|---|---|
Optional[QIcon]
|
The current icon, or None if no icon is set. |
set_content_layout
¶
set_content_layout(content_layout: QLayout) -> None
Set the layout for the content area.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content_layout
¶ |
QLayout
|
The layout to set for the content area. |
required |
set_content_widget
¶
set_content_widget(widget: QWidget) -> None
Set the content widget directly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
widget
¶ |
QWidget
|
The widget to display when expanded. |
required |
set_icon
¶
set_title
¶
set_title_icon
¶
Set the title icon (deprecated, use set_icon).