码迷,mamicode.com
首页 > 其他好文 > 详细

PyQt5-网格布局(QGridLayout)-11

时间:2018-09-30 18:15:01      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:title   输入   names   widgets   range   图片   qt5   option   __name__   

 1 #demo_12:网格布局
 2 import sys
 3 from PyQt5.QtWidgets import  QApplication,QWidget,QGridLayout,QPushButton,QLineEdit,QTextEdit,QLabel
 4 
 5 class Example(QWidget):
 6     def __init__(self):
 7         super().__init__()
 8         self.initUI()
 9     def initUI(self):
10         layout=QGridLayout()
11         title_label=QLabel(Title)
12 
13         layout.addWidget(title_label,0,0)#将label组件加入到布局layout中,后面参数标示行下标,列下标
14         text_titleEdit=QLineEdit()   #单行输入文本
15         layout.addWidget(text_titleEdit,0,1)
16 
17         author_label = QLabel(Author)
18         layout.addWidget(author_label, 1, 0)
19         text_authorEdit = QLineEdit() #单行输入文本
20         layout.addWidget(text_authorEdit, 1, 1)
21 
22         desc_label=QLabel(Desc)
23 
24         layout.addWidget(desc_label,2,0)
25         text_descEdit=QTextEdit()    #多行输入文本
26         layout.addWidget(text_descEdit,2,1)
27 
28         self.setLayout(layout)
29 
30         self.setGeometry(500, 250, 350, 300)
31         self.setWindowTitle(Calculator)
32         self.show()
33 if __name__==__main__:
34     app=QApplication(sys.argv)
35     e=Example()
36     sys.exit(app.exec())
37 
38 # names = [‘Cls‘, ‘Bck‘, ‘‘, ‘Close‘,
39 #              ‘7‘, ‘8‘, ‘9‘, ‘/‘,
40 #              ‘4‘, ‘5‘, ‘6‘, ‘*‘,
41 #              ‘1‘, ‘2‘, ‘3‘, ‘-‘,
42 #              ‘0‘, ‘.‘, ‘=‘, ‘+‘]
43 # options = [(i, j) for j in range(5) for i in range(4)]
44 # for position, name in zip(options, names):
45 #     print(str(position)+"》》"+str(name))

技术分享图片

 

PyQt5-网格布局(QGridLayout)-11

标签:title   输入   names   widgets   range   图片   qt5   option   __name__   

原文地址:https://www.cnblogs.com/ygzhaof/p/9732650.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!