-
Notifications
You must be signed in to change notification settings - Fork 1
/
progress_bar.py
37 lines (29 loc) · 1.07 KB
/
progress_bar.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
from time import sleep
def progress_bar(value, maximum):
'''
def progress_bar(value, maximum):
Will print progress bar for data loading status rescaling in percentage.
value = Value that will be loaded
maximum = Maximum value for scaling
Example:
Such as 40 out of 200
value = 40
maximum = 200
'''
value = int((value/maximum)*100)
for i in range(1, value+1):
sleep(.3)
rightbar, leftbar, inchar, emptychar, width = "▌", " ▌", "█", '▬', 100
fill_val = inchar*i
empty_val = emptychar*(width-i)
status = str(int((i/width)*100))
if i == value:
status += "% Loaded"
else:
status += "% Loading"
print(rightbar+fill_val+empty_val+leftbar+status, end="\r")
print("\n")
if __name__ == '__main__':
value, maximum = map(int, input("Input value & maximum = ").split(' '))
print("\n")
progress_bar(value, maximum)