accordion
_accordion
¶
Multi-section collapsible widget (accordion).
Classes:
| Name | Description |
|---|---|
FXAccordion |
A multi-section collapsible accordion widget. |
FXAccordionSection |
Deprecated: Use FXCollapsibleWidget instead. |
Classes¶
FXAccordion
¶
FXAccordion(
parent: Optional[QWidget] = None,
exclusive: bool = True,
animation_duration: int = 150,
)
Bases: QWidget
flowchart TD
fxgui.fxwidgets._accordion.FXAccordion[FXAccordion]
click fxgui.fxwidgets._accordion.FXAccordion href "" "fxgui.fxwidgets._accordion.FXAccordion"
A multi-section collapsible accordion widget.
Uses FXCollapsibleWidget for each section. By default, only one section can be open at a time (exclusive mode).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Optional[QWidget]
|
Parent widget. |
None
|
|
bool
|
If True, only one section can be open at a time. |
True
|
|
int
|
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, icon="settings")
>>> accordion.add_section("Advanced", advanced_content, icon="tune")
>>> accordion.add_section("Info", info_content, icon="info")
Methods:
| Name | Description |
|---|---|
__iter__ |
Iterate over sections. |
__len__ |
Return the number of sections. |
add_section |
Add a new section to the accordion. |
collapse_all |
Collapse all sections. |
collapse_section |
Collapse a section by index. |
expand_all |
Expand all sections (only works if not exclusive). |
expand_section |
Expand a section by index. |
get_section |
Get a section by index. |
remove_section |
Remove a section by index. |
Attributes:
| Name | Type | Description |
|---|---|---|
exclusive |
bool
|
Return whether accordion is in exclusive mode. |
Attributes¶
Functions¶
add_section
¶
add_section(
title: str,
content: Optional[Union[QWidget, QLayout]] = None,
icon: Optional[str] = None,
) -> FXCollapsibleWidget
Add a new section to the accordion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
¶ |
str
|
Section title. |
required |
content
¶ |
Optional[Union[QWidget, QLayout]]
|
Content widget or layout. |
None
|
icon
¶ |
Optional[str]
|
Optional icon name for the header. |
None
|
Returns:
| Type | Description |
|---|---|
FXCollapsibleWidget
|
The created FXCollapsibleWidget. |
collapse_section
¶
expand_section
¶
get_section
¶
get_section(index: int) -> Optional[FXCollapsibleWidget]
Get a section by index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
¶ |
int
|
The section index. |
required |
Returns:
| Type | Description |
|---|---|
Optional[FXCollapsibleWidget]
|
The FXCollapsibleWidget or None if index is invalid. |
FXAccordionSection
¶
FXAccordionSection(
parent: Optional[QWidget] = None,
title: str = "",
icon: Optional[str] = None,
animation_duration: int = 150,
)
Bases: FXCollapsibleWidget
flowchart TD
fxgui.fxwidgets._accordion.FXAccordionSection[FXAccordionSection]
fxgui.fxwidgets._collapsible.FXCollapsibleWidget[FXCollapsibleWidget]
fxgui.fxstyle.FXThemeAware[FXThemeAware]
fxgui.fxwidgets._collapsible.FXCollapsibleWidget --> fxgui.fxwidgets._accordion.FXAccordionSection
fxgui.fxstyle.FXThemeAware --> fxgui.fxwidgets._collapsible.FXCollapsibleWidget
click fxgui.fxwidgets._accordion.FXAccordionSection href "" "fxgui.fxwidgets._accordion.FXAccordionSection"
click fxgui.fxwidgets._collapsible.FXCollapsibleWidget href "" "fxgui.fxwidgets._collapsible.FXCollapsibleWidget"
click fxgui.fxstyle.FXThemeAware href "" "fxgui.fxstyle.FXThemeAware"
Deprecated: Use FXCollapsibleWidget instead.
This class is kept for backward compatibility only.