PyQt5 Tutorial - Grid Layout

PyQt5 Tutorial - Grid Layout

We will learn another layout method in PyQt5 in this tutorial - grid layout. PyQt5 Grid Layout The QGridLayout class lays out widgets in a grid. QGridLayout takes the available space to it and divides it up into rows and columns and then puts each widget into the correct cell. import sys from PyQt5.QtWidgets import QWidget, QGridLayout, QPushButton, QApplication class basicWindow(QWidget): def __init__(self): super().__init__() grid_layout = QGridLayout() self.setLayout(grid_layout) for x in range(3): for y in range(3): button = QPushButton(str(str(3 * x + y))) grid_layout.

Tags

PyQt5 Button PyQt5 Menubar

Most Popular Articles

Recently Updated Articles