-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample.py
More file actions
136 lines (111 loc) · 4.41 KB
/
Copy pathexample.py
File metadata and controls
136 lines (111 loc) · 4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import sys
from PySide6.QtWidgets import (
QApplication, QMainWindow, QWidget, QVBoxLayout, QLabel, QLineEdit,
QComboBox, QCheckBox, QRadioButton, QSlider, QProgressBar,
QSpinBox, QDateEdit, QTextEdit, QPushButton
)
from PySide6.QtCore import Qt
from collapsiblepane import CollapsiblePane
class Window(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("CollapsiblePane – Full Customization Demo")
self.resize(600, 700)
# --- Collapsible Section ---
section = CollapsiblePane("User Details", animation_duration=400)
# --- Header customization ---
section.set_header_style(
background_color="#28a745", # Green header
text_color="#FFFFFF", # White text for contrast
border_color="#1c7c1c", # Darker green border
border_width=2,
font_size=16,
font_weight="bold",
hover_color="#32cd32" # Lighter green hover
)
# --- Chevron customization ---
section.set_chevron_icons("▸", "▾")
# --- Card content style ---
section.set_card_style(
background="#f0fdf4", # Soft light green background
border="#28a74533", # Subtle green border
radius=10,
padding=12
)
# --- Item count badge ---
section.set_item_count(23)
section.set_item_badge_style(
bg_color="#ffd6e0", # Light pink
text_color="#e91e63", # Dark pink text
border_color="#ff80ab", # Matching border
border_radius=12,
padding_vertical=4,
padding_horizontal=12,
font_size=12,
font_weight="bold",
shadow=True,
min_width=40
)
# --- Title style ---
section.set_title_style(color="#ffffff", font_weight="bold", italic=False)
# --- Content text style ---
section.set_content_text_style(color="#333333", font_size=14)
# --- Content Widget ---
content_widget = QWidget()
content_layout = QVBoxLayout(content_widget)
content_layout.setSpacing(8)
# User input fields
details_edit = QLineEdit()
details_edit.setPlaceholderText("Details here...")
content_layout.addWidget(details_edit)
name_edit=QLineEdit()
name_edit.setPlaceholderText("Name here...")
content_layout.addWidget(name_edit)
email_edit = QLineEdit()
email_edit.setPlaceholderText("Email here...")
content_layout.addWidget(email_edit)
# Category selection
content_layout.addWidget(QLabel("Select a category:"))
combo = QComboBox()
combo.addItems(["Developer", "Designer", "Security Researcher", "Engineer"])
content_layout.addWidget(combo)
# Preferences
content_layout.addWidget(QCheckBox("Subscribe to newsletter"))
content_layout.addWidget(QRadioButton("Light Mode"))
content_layout.addWidget(QRadioButton("Dark Mode"))
# Volume and progress
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)
# Additional inputs
content_layout.addWidget(QSpinBox())
content_layout.addWidget(QDateEdit())
# Bio
content_layout.addWidget(QLabel("Bio:"))
text_edit = QTextEdit()
text_edit.setPlaceholderText("Tell us about yourself...")
content_layout.addWidget(text_edit)
# Submit button
content_layout.addWidget(QPushButton("Submit"))
# Set the content widget
section.set_content_widget(content_widget)
# Force collapsed initially
section.set_collapsed(collapsed=True)
# --- Layout Setup ---
container = QWidget()
main_layout = QVBoxLayout(container)
main_layout.addWidget(section)
toggle_button = QPushButton("Toggle Section")
toggle_button.clicked.connect(lambda: section.toggle(not section._expanded))
main_layout.addWidget(toggle_button)
main_layout.addStretch()
self.setCentralWidget(container)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec())