Accordion¶
The accordion widget provides a container with multiple collapsible sections, where only one or multiple sections can be expanded at a time.
Preview
Classes¶
FXAccordion
¶
Bases:
A multi-section collapsible accordion widget.
Like FXCollapsibleWidget but for multiple mutually-exclusive sections (only one section open at a time by default).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
|
Parent widget. |
None
|
|
|
If True, only one section can be open at a time. |
True
|
|
|
Duration of expand/collapse animation in ms. |
150
|
Signals
section_expanded: Emitted when a section is expanded (section index). section_collapsed: Emitted when a section is collapsed (section index).
Examples:
>>> accordion = FXAccordion()
>>> accordion.add_section("General", general_content)
>>> accordion.add_section("Advanced", advanced_content)
>>> accordion.add_section("Settings", settings_content)
Methods:
| Name | Description |
|---|---|
|
Iterate over sections. |
|
Return the number of sections. |
|
Add a new section to the accordion. |
|
Collapse all sections. |
|
Collapse a section by index. |
|
Expand all sections (only works if not exclusive). |
|
Expand a section by index. |
|
Get a section by index. |
|
Remove a section by index. |
add_section
¶
add_section(
title : str ,
content : Optional [Union [QWidget , QVBoxLayout ]] = None,
icon : Optional [str ] = None,
) -> FXAccordionSection
Add a new section to the accordion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
|
Section title. |
required |
|
|
Content widget or layout. |
None
|
|
|
Optional icon name for the header. |
None
|
Returns:
| Type | Description |
|---|---|
|
The created FXAccordionSection. |
collapse_section
¶
Collapse a section by index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
|
The section index to collapse. |
required |
expand_section
¶
Expand a section by index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
|
The section index to expand. |
required |
FXAccordionSection
¶
Bases: ,
A single section of the accordion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
|
Parent widget. |
None
|
|
|
Section title. |
''
|
|
|
Optional icon name for the section header. |
None
|
|
|
Duration of expand/collapse animation in ms. |
150
|
Signals
expanded: Emitted when the section is expanded. collapsed: Emitted when the section is collapsed.
Methods:
| Name | Description |
|---|---|
|
Collapse the section. |
|
Expand the section. |
|
Set the content layout for this section. |
|
Set the content widget for this section. |
|
Toggle the section state. |
Attributes:
| Name | Type | Description |
|---|---|---|
|
|
Return whether the section is expanded. |
|
|
Return the section title. |
collapse
¶
Collapse the section.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
|
Whether to animate the collapse. |
True
|
expand
¶
Expand the section.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
|
Whether to animate the expansion. |
True
|
set_content_layout
¶
Set the content layout for this section.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
|
The layout to use for content. |
required |