PyQt5--InputDiaglog

2018-09-18 06:44:48来源:博客园 阅读 ()

新老客户大回馈,云服务器低至5折

 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_())

 

 

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Python_序列化和反序列化模块

下一篇:PyQt5--MainWindow