学习《PyQt4入门指南 PDF中文版.pdf 》笔记
最通用的布局类别是网格布局(QGridLayout)。该布局方式将窗口空间划分为许多行和列。要创建该布局方式,我们需要实用QGridLayout类。
#!/usr/bin/python
# gridlayout.py
from PyQt5.QtWidgets import QApplication, QPushButton, QLabel, QGridLayout
from PyQt5 import QtWidgets
class GridLayout(QtWidgets.QWidget):
def __init__(self, parent= None):
QtWidgets.QWidget.__init__(self)
self.setWindowTitle('grid layout')
names = ['Cls', 'Bck','', 'Close', '7', '8', '9', '/',
'4', '5', '6', '*', '1', '2', '3', '-', '0', '.', '=', '+']
grid = QGridLayout()
j = 0
pos = [(0, 0), (0, 1), (0, 2), (0, 3),
(1, 0), (1, 1), (1, 2), (1, 3),
(2, 0), (2, 1,), (2, 2), (2, 3),
(3, 0), (3, 1,), (3, 2), (3