forked from wolph/python-progressbar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom_widgets.py
More file actions
32 lines (26 loc) · 869 Bytes
/
custom_widgets.py
File metadata and controls
32 lines (26 loc) · 869 Bytes
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
import progressbar
class CrazyFileTransferSpeed(progressbar.FileTransferSpeed):
"It's bigger between 45 and 80 percent"
def update(self, pbar):
if 45 < pbar.percentage() < 80:
return 'Bigger Now ' + progressbar.FileTransferSpeed.update(self,
pbar)
else:
return progressbar.FileTransferSpeed.update(self, pbar)
def test_crazy_file_transfer_speed_widget():
widgets = [
# CrazyFileTransferSpeed(),
' <<<',
progressbar.Bar(),
'>>> ',
progressbar.Percentage(),
' ',
progressbar.ETA(),
]
p = progressbar.ProgressBar(widgets=widgets, max_value=1000)
# maybe do something
p.start()
for i in range(0, 200, 5):
# do something
p.update(i + 1)
p.finish()