PyQt5--QProgressBar

 1 # -*- coding:utf-8 -*-
 2 '''
 3 Created on Sep 20, 2018
 4 
 5 @author: SaShuangYiBing
 6 
 7 Comment: 
 8 '''
 9 import sys 
10 from PyQt5.QtCore import QBasicTimer
11 from PyQt5.QtWidgets import QApplication,QWidget,QProgressBar,QPushButton
12 
13 class New_test(QWidget):
14     def __init__(self):
15         super().__init__()
16         self.initUI()
17         
18     def initUI(self):
19         self.pbar = QProgressBar(self)
20         self.pbar.setGeometry(30,40,200,25)
21         
22         self.btn = QPushButton('Start',self)
23         self.btn.move(75,80)
24         self.btn.clicked.connect(self.doAction)
25         
26         self.timer = QBasicTimer()
27         self.step = 0
28         
29         self.setGeometry(300,300,280,170)
30         self.setWindowTitle('QProgress Bar')
31         self.show()
32     
33     def timerEvent(self, e):
34         if self.step >= 100:
35             self.timer.stop()
36             self.btn.setText('Finished')
37             return
38         self.step += 1
39         self.pbar.setValue(self.step)
40         
41     def doAction(self,e):
42         if self.timer.isActive():
43             self.timer.stop()
44             self.btn.setText('Start')
45         else:
46             self.timer.start(100,self)
47             self.btn.setText('Stop')
48 
49 if __name__ == '__main__':
50     app = QApplication(sys.argv)
51     ex = New_test()
52     sys.exit(app.exec_())

 

 

转载于:https://www.cnblogs.com/aziji/p/9680241.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值