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

PyQt5--InputDiaglog

时间:2018-09-14 18:24:48      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:import   bsp   from   elf   except   nec   ted   button   http   

 1 # -*- coding:utf-8 -*-
 2 ‘‘‘
 3 Created on Sep 14, 2018
 4 
 5 @author: SaShuangYiBing
 6 
 7 Comment: 
 8 ‘‘‘
 9 import sys
10 from PyQt5.QtWidgets import QApplication,QInputDialog,QLineEdit,QPushButton,QWidget
11 
12 class New_test(QWidget):
13     def __init__(self):
14         super().__init__()
15         self.initUI()
16     
17     def initUI(self):
18         self.btn = QPushButton(Diaglog,self)
19         self.btn.move(20,20)
20         self.btn.clicked.connect(self.showDiaglog)
21         
22         self.le = QLineEdit()
23         self.le.move(130,22)
24         
25         self.setGeometry(300,300,290,150)
26         self.setWindowTitle(Input Diaglog)
27         self.show()
28         
29     def showDiaglog(self):
30         try:
31             text,ok = QInputDialog.getText(self,Input Diaglog,Enter your name)
32             if ok:
33                 self.le.setText(str(text))
34         except Exception as e:
35             print (e)
36             
37 if __name__ == __main__:
38     app = QApplication(sys.argv)
39     ex = New_test()
40     sys.exit(app.exec_())

 

技术分享图片

 

PyQt5--InputDiaglog

标签:import   bsp   from   elf   except   nec   ted   button   http   

原文地址:https://www.cnblogs.com/SaShuangYiBing/p/9648079.html

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