A PySide6 widget for collapsible panels, inspired by JavaFX's TitledPane
Project description
CollapsiblePane (PySide6) 
The CollapsiblePane is a reusable and customizable PySide6 widget that allows users to toggle the visibility of a content area with smooth animations—perfect for organizing UI sections. It mimics JavaFX’s TitledPane behavior and is designed to cleanly encapsulate widgets within collapsible sections.
Inspired by JavaFX's TitledPane.
Features
- Expand/Collapse content with animation
- Fully customizable title bar and content styling
- Add or replace content widgets easily
- Clean, layout-friendly design
- Signal support for toggled state
Usage
import sys
from PySide6.QtWidgets import (
QMainWindow, QVBoxLayout, QLabel, QPushButton, QLineEdit,
QComboBox, QCheckBox, QRadioButton, QSlider, QProgressBar,
QSpinBox, QDateEdit, QTextEdit, QWidget, QApplication
)
from PySide6.QtCore import Qt
from collapsiblepane import CollapsiblePane
class Window(QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle("Collapsible Pane Demo")
# Create the collapsible pane
section = CollapsiblePane("Example Section", 150, self)
# Customize title bar appearance
section.set_title_bar_style(background_color="#0066ff", foreground_color="#FFFFFF")
section.set_content_style(
background_color="#FFFFFF",
border_color="#0066FF",
border_width=2,
border_style="solid"
)
# Create a widget to hold form elements
content_widget = QWidget()
content_layout = QVBoxLayout(content_widget)
content_layout.addWidget(QLabel("Enter your details:"))
content_layout.addWidget(QLineEdit("Name here..."))
content_layout.addWidget(QLineEdit("Email address..."))
content_layout.addWidget(QLabel("Select a category:"))
combo = QComboBox()
combo.addItems(["Developer", "Designer", "Security Researcher", "Engineer"])
content_layout.addWidget(combo)
content_layout.addWidget(QCheckBox("Subscribe to newsletter"))
content_layout.addWidget(QRadioButton("Light Mode"))
content_layout.addWidget(QRadioButton("Dark Mode"))
content_layout.addWidget(QLabel("Volume:"))
slider = QSlider(Qt.Horizontal)
slider.setValue(40)
content_layout.addWidget(slider)
progress = QProgressBar()
progress.setValue(70)
content_layout.addWidget(progress)
content_layout.addWidget(QSpinBox())
content_layout.addWidget(QDateEdit())
content_layout.addWidget(QLabel("Bio:"))
text_edit = QTextEdit()
text_edit.setPlaceholderText("Tell us about yourself...")
content_layout.addWidget(text_edit)
content_layout.addWidget(QPushButton("Submit"))
# Set the content widget
section.content_widget = content_widget
# Main layout setup
container = QWidget()
main_layout = QVBoxLayout(container)
main_layout.addWidget(section)
# Button to clear collapsible pane content
clear_button = QPushButton("Clear Section", self)
clear_button.clicked.connect(section.clear_widget)
main_layout.addWidget(clear_button)
main_layout.setAlignment(section, Qt.AlignTop)
self.setCentralWidget(container)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = Window()
window.resize(400, 300)
window.show()
sys.exit(app.exec())
Screenshot
| Collapsed | Expanded |
|---|---|
API Overview
Constructor
CollapsiblePane(title="", animation_duration=100)
Properties
content_widget:QWidgetis_expanded:bool
Methods
clear_widget()set_content_style(background_color, border_color, ...)set_title_bar_style(background_color, foreground_color)
Signals
toggled(bool)— emits when pane expands or collapses
Contributions
For contributions please visit Github Repository
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file collapsiblepane-0.10.21.tar.gz.
File metadata
- Download URL: collapsiblepane-0.10.21.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19ba22a346a6962902cac7ca6516fdad8913a0ef558b251974e243ea5c85eb2f
|
|
| MD5 |
cdc85c82abd6275d12988d2c9876afbf
|
|
| BLAKE2b-256 |
eb1d76e02db52bb6a51e46423d50bd21616e3638c9faec415638a473a8e95a3a
|
File details
Details for the file collapsiblepane-0.10.21-py3-none-any.whl.
File metadata
- Download URL: collapsiblepane-0.10.21-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d364812a1a0a07f312d3468b911c7d66b57a13aa840dc4f7c555aba6cf7459a2
|
|
| MD5 |
6936dc8bad33838fd2b6f7505bb1c33e
|
|
| BLAKE2b-256 |
f23ea790e0fbd1470b560881cacc3a6c2b1f43a094a0e31803b482302d2427f0
|