-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdynamic_Gridlayout.py
More file actions
37 lines (24 loc) · 945 Bytes
/
dynamic_Gridlayout.py
File metadata and controls
37 lines (24 loc) · 945 Bytes
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
from PySide import QtCore, QtGui
class DynamicGridlayout(QtGui.QWidget):
def __init__(self):
super(DynamicGridlayout,self).__init__()
mainLayout = QtGui.QVBoxLayout(self)
grid = QtGui.QGridLayout()
# you can directly control the spacing here
grid.setSpacing(20)
for row in xrange(5):
grid.addWidget(QtGui.QLabel("Text"), row, 0,
1, 1, QtCore.Qt.AlignTop)
grid.addWidget(QtGui.QLabel(str(row)), row, 1,
1, 1, QtCore.Qt.AlignTop)
grid.addWidget(QtGui.QPushButton('TESt'), row, 2,
1, 1, QtCore.Qt.AlignTop)
mainLayout.addLayout(grid)
mainLayout.addStretch()
self.setLayout(mainLayout)
if __name__ == '__main__':
import sys
app = QtGui.QApplication(sys.argv)
dialog = DynamicGridlayout()
dialog.show()
sys.exit(app.exec_())