PyQt5--GridLayoutMul

发布时间:2019-03-10 19:53:53编辑:auto阅读(2346)

     1 # -*- coding:utf-8 -*-
     2 '''
     3 Created on Sep 13, 2018
     4 
     5 @author: SaShuangYiBing
     6 '''
     7 import sys
     8 from PyQt5.QtWidgets import QApplication,QWidget,QGridLayout,QLabel,QLineEdit,QTextEdit
     9 
    10 class New_test(QWidget):
    11     def __init__(self):
    12         super().__init__()
    13         self.initUI()
    14         
    15     def initUI(self):
    16         title = QLabel('Title:')
    17         author = QLabel('Author:')
    18         review = QLabel('Review:')
    19         
    20         titleEdit = QLineEdit()
    21         authorEdit = QLineEdit()
    22         reviewEdit = QTextEdit()
    23         
    24         grid = QGridLayout()
    25         grid.setSpacing(10)
    26         
    27         grid.addWidget(title,1,0)
    28         grid.addWidget(titleEdit,1,1)
    29         grid.addWidget(author,2,0)
    30         grid.addWidget(authorEdit,2,1)
    31         grid.addWidget(review,3,0)
    32         grid.addWidget(reviewEdit,3,1,3,1) # 放置在第3行第1列,占用3行且保占1列
    33         
    34         self.setLayout(grid)
    35         
    36         self.setGeometry(300,300,350,300)
    37         self.setWindowTitle('Review')
    38         self.show()
    39         
    40 if __name__ == "__main__":
    41     app = QApplication(sys.argv)
    42     ex = New_test()
    43     sys.exit(app.exec_())
    44         
    45         

     

     

关键字

上一篇: Python_模块介绍

下一篇: canda 常用命令