-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathusage.py
More file actions
86 lines (62 loc) · 1.91 KB
/
Copy pathusage.py
File metadata and controls
86 lines (62 loc) · 1.91 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
"""usage.py
Example usage of the Collapsable Frame widget.
"""
import sys
from Qt.QtWidgets import (
QApplication,
QMainWindow,
QWidget,
QVBoxLayout,
QGridLayout,
QLabel,
QLineEdit,
QPushButton
)
from Qt.QtCore import Qt as qt
from collapsable_frame import CollapsableFrame
def run(*args):
if not QApplication.instance():
app = QApplication(*args)
else:
app = QApplication.instance()
window = QMainWindow()
widget = QWidget()
widget.setMinimumWidth(350)
window.setCentralWidget(widget)
layout = QVBoxLayout()
layout.setAlignment(qt.AlignTop)
widget.setLayout(layout)
# Vertical layout widget
vertical_widget = QWidget()
vertical_layout = QVBoxLayout()
vertical_widget.setLayout(vertical_layout)
vertical_layout.addWidget(QPushButton("Button 1"))
vertical_layout.addWidget(QPushButton("Button 2"))
vertical_layout.addWidget(QPushButton("Button 3"))
# Set widget in collapsable frame
frame_vertical = CollapsableFrame(title="Vertical")
frame_vertical.setContent(vertical_widget)
layout.addWidget(frame_vertical)
# Grid layout widget
grid_widget = QWidget()
grid_layout = QGridLayout()
grid_widget.setLayout(grid_layout)
label1 = QLabel("Label 1:")
label1.setAlignment(qt.AlignVCenter)
grid_layout.addWidget(label1, 0, 0, 1, 1)
grid_layout.addWidget(QLineEdit(), 0, 1, 1, 1)
label2 = QLabel("Label 2:")
label2.setAlignment(qt.AlignVCenter)
grid_layout.addWidget(label2, 1, 0, 1, 1)
grid_layout.addWidget(QLineEdit(), 1, 1, 1, 1)
# Set widget in collapsable frame
frame_grid = CollapsableFrame(title="Grid")
frame_grid.setContent(grid_widget)
layout.addWidget(frame_grid)
layout.addStretch(1)
window.show()
window.raise_()
return app.exec_()
if __name__ == "__main__":
return_code = run(sys.argv)
sys.exit(return_code)