-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogress_window.py
60 lines (39 loc) · 1.3 KB
/
progress_window.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'progress_bar.ui'
#
# Created by: PyQt5 UI code generator 5.15.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
import sys, main
from PyQt5.QtWidgets import (QWidget, QProgressBar, QApplication)
from PyQt5.QtCore import QBasicTimer
class Example(QWidget):
def __init__(self, finish):
super().__init__()
self.initUI()
self.finish = finish
def initUI(self):
self.pbar = QProgressBar(self)
self.pbar.setGeometry(30, 40, 430, 25)
self.timer = QBasicTimer()
self.step = 0
self.setGeometry(300, 300, 480, 80)
self.setWindowTitle('QProgressBar')
self.doAction()
self.show()
def timerEvent(self, e):
if self.step >= self.finish:
self.timer.stop()
return 0
self.step = main.getSizeDownloadingFile()
self.pbar.setValue(self.step)
def doAction(self):
if self.timer.isActive():
self.timer.stop()
else:
self.timer.start(self.finish, self)
def callDownloader(finish):
app = QApplication(sys.argv)
ex = Example(finish)
sys.exit(app.exec_())