You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
859 B
47 lines
859 B
2 years ago
|
# Filename: g_layout.py
|
||
|
|
||
|
|
||
|
"""Grid layout example."""
|
||
|
|
||
|
|
||
|
import sys
|
||
|
|
||
|
|
||
|
from PyQt5.QtWidgets import QApplication
|
||
|
|
||
|
from PyQt5.QtWidgets import QGridLayout
|
||
|
|
||
|
from PyQt5.QtWidgets import QPushButton
|
||
|
|
||
|
from PyQt5.QtWidgets import QWidget
|
||
|
|
||
|
|
||
|
app = QApplication(sys.argv)
|
||
|
|
||
|
window = QWidget()
|
||
|
|
||
|
window.setWindowTitle('QGridLayout')
|
||
|
|
||
|
layout = QGridLayout()
|
||
|
|
||
|
layout.addWidget(QPushButton('Button (0, 0)'), 0, 0)
|
||
|
|
||
|
layout.addWidget(QPushButton('Button (0, 1)'), 0, 1)
|
||
|
|
||
|
layout.addWidget(QPushButton('Button (0, 2)'), 0, 2)
|
||
|
|
||
|
layout.addWidget(QPushButton('Button (1, 0)'), 1, 0)
|
||
|
|
||
|
layout.addWidget(QPushButton('Button (1, 1)'), 1, 1)
|
||
|
|
||
|
layout.addWidget(QPushButton('Button (1, 2)'), 1, 2)
|
||
|
|
||
|
layout.addWidget(QPushButton('Button (2, 0)'), 2, 0)
|
||
|
|
||
|
layout.addWidget(QPushButton('Button (2, 1) + 2 Columns Span'), 2, 1, 1, 2)
|
||
|
|
||
|
window.setLayout(layout)
|
||
|
|
||
|
window.show()
|
||
|
|
||
|
sys.exit(app.exec_())
|