forked from wolph/python-progressbar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_custom_widgets.py
More file actions
43 lines (34 loc) · 1.19 KB
/
test_custom_widgets.py
File metadata and controls
43 lines (34 loc) · 1.19 KB
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
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()
def test_dynamic_message_widget():
widgets = [' [', progressbar.Timer(), '] ', progressbar.Bar(), ' (',
progressbar.ETA(), ') ', progressbar.DynamicMessage('loss')]
p = progressbar.ProgressBar(widgets=widgets, max_value=1000)
p.start()
for i in range(0, 200, 5):
p.update(i + 1, loss=.5)
p.finish()