QCollapsible¶
A QFrame with a header button that
hides or shows its contents, with an animation. Add contents with addWidget.
expand()andcollapse()open and close it from code (passanimate=Falseto skip the animation), andtoggledemitsTrueorFalsewhen it opens or closes.setExpandedIconandsetCollapsedIconchange the header's icons (aQIcon, or a string such as"▼"), andsetDurationandsetEasingCurvechange the animation.setLocked(True)keeps it from opening or closing, until it's unlocked.
from qtpy.QtWidgets import QApplication, QLabel, QPushButton
from superqt import QCollapsible
app = QApplication([])
collapsible = QCollapsible("Advanced analysis")
collapsible.addWidget(QLabel("This is the inside of the collapsible frame"))
for i in range(4):
collapsible.addWidget(QPushButton(f"Content button {i + 1}"))
collapsible.expand(animate=False)
collapsible.show()
app.exec()
QCollapsible
¶
QCollapsible(
title: str = "",
parent: QWidget | None = None,
expandedIcon: QIcon | str | None = "▼",
collapsedIcon: QIcon | str | None = "▲",
)
A collapsible widget to hide and unhide child widgets.
A signal is emitted when the widget is expanded (True) or collapsed (False).
Based on https://stackoverflow.com/a/68141638
Subclass of QFrame
QCollapsible inherits all of QFrame's methods, signals, and properties. Only those that superqt adds or changes are listed here.
Signals¶
toggled(bool)
Methods¶
A collapsible widget to hide and unhide child widgets.
A signal is emitted when the widget is expanded (True) or collapsed (False).
Based on https://stackoverflow.com/a/68141638
removeWidget
¶
Remove widget from the central content widget's layout.
setCollapsedIcon
¶
setCollapsedIcon(icon: QIcon | str | None = None) -> None
Set the icon on the toggle button when the widget is collapsed.
setContent
¶
Replace central widget (the widget that gets expanded/collapsed).
setEasingCurve
¶
Set the easing curve for the collapse/expand animation.