10000 Add QGridLayout example · realpython/materials@1798400 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1798400

Browse files
committed
Add QGridLayout example
1 parent 2f1c72c commit 1798400

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# filename: g_layout.py
2+
3+
"""Grid layout example."""
4+
5+
import sys
6+
7+
from PyQt5.QtWidgets import QApplication
8+
from PyQt5.QtWidgets import QWidget
9+
from PyQt5.QtWidgets import QPushButton
10+
from PyQt5.QtWidgets import QGridLayout
11+
12+
app = QApplication(sys.argv)
13+
window = QWidget()
14+
window.setWindowTitle('QGridLayout')
15+
layout = QGridLayout()
16+
layout.addWidget(QPushButton('Button (0, 0)'), 0, 0)
17+
layout.addWidget(QPushButton('Button (0, 1)'), 0, 1)
18+
layout.addWidget(QPushButton('Button (0, 2)'), 0, 2)
19+
layout.addWidget(QPushButton('Button (1, 0)'), 1, 0)
20+
layout.addWidget(QPushButton('Button (1, 1)'), 1, 1)
21+
layout.addWidget(QPushButton('Button (1, 2)'), 1, 2)
22+
layout.addWidget(QPushButton('Button (2, 0)'), 2, 0)
23+
layout.addWidget(QPushButton('Button (2, 1) + 2 Columns Span'), 2, 1, 1, 2)
24+
window.setLayout(layout)
25+
window.show()
26+
sys.exit(app.exec_())

0 commit comments

Comments
 (0)
0