# -*- coding: cp936 -*-
import sys
from PyQt4 import QtGui,QtCore
class GridLayout(QtGui.QWidget):
def __init__(self,parent=None):
QtGui.QWidget.__init__(self)
self.setWindowTitle(‘grid layout‘)
title=QtGui.QLabel(‘Titel:‘)
authot=QtGui.QLabel(‘Auhot:‘)
review=QtGui.QLabel(‘Review:‘)
titleEdit=QtGui.QLineEdit()
authotEdit=QtGui.QLineEdit()
reviewEdit=QtGui.QLineEdit()
grid=QtGui.QGridLayout()
grid.setSpacing(0.1)
grid.addWidget(title,1,0)
grid.addWidget(titleEdit,1,1)
grid.addWidget(authot,2,0)
grid.addWidget(authotEdit,2,1)
grid.addWidget(review,3,0)
grid.addWidget(reviewEdit,3,1)
self.setLayout(grid)
self.resize(350,300)
app=QtGui.QApplication(sys.argv)
qb=GridLayout()
qb.show()
sys.exit(app.exec_())
如图:
时间: 2024-10-07 05:39:33