This repository was archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpy_load.py
More file actions
70 lines (57 loc) · 1.96 KB
/
py_load.py
File metadata and controls
70 lines (57 loc) · 1.96 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class LoadingBar:
"""
Py-Load main class.
"""
def __init__(self, total: int, borderChars = ["[", "]"], progressChar: str = "#", emptyChar: str = " ", barLength = 50):
"""
Initialize the Loading Bar.
Customize the way it looks by specifying the `borderChars`, `progressChar`, and `emptyChar` arguements.
You can do this by doing `<loadingBarName>.<arguementName> = <value>`.
This can also be specified when initializing.
"""
self.total = total
"""The total/max value of the loading bar."""
self.progress = 0
"""The progress value of the loading bar. Not a precentage."""
self.borderChars = borderChars
"""
Default: "[", "]"
A list that should have two values, the opening border character and the closing border character.
They surround the loading bar's progress meter.
Eg:
```
...
myLoadingBar.borderChars = ["{", "}"]
myLoadingBar.display()
```
Output: `{##########}`
"""
self.progressChar = progressChar
"""
Default: "#"
The progress character / the fill character.
"""
self.emptyChar = emptyChar
"""
Default: " " (space)
The empty character
"""
self.barLength = barLength
"""
Default: 50
The length (in characters) of the loading bar.
"""
def display(self):
"""
Display the Loading Bar.
"""
percent = round((self.progress / self.total) * self.barLength)
toPrint = ""
toPrint += self.borderChars[0]
for i in range(percent):
if len(toPrint) < (self.barLength + len(self.borderChars[0])):
toPrint += self.progressChar
for i in range(self.barLength - percent):
toPrint += self.emptyChar
toPrint += self.borderChars[1]
return(toPrint)