|
3 | 3 | # TO USE IN YOUR CODE |
4 | 4 | #from folder.ProgressBar import ProgressBar |
5 | 5 |
|
| 6 | +# Class: ProgressBar |
| 7 | +# Role: Set progress bar parameters and define its printing functions |
6 | 8 | class ProgressBar: |
7 | 9 | def __init__(self, |
8 | 10 | pretext=r"", # Text to print before the bar |
9 | 11 | progresschar=r"█", # Character to show progress |
| 12 | + remainingbarchar=r" ", # Character to fill the remaining bar with |
10 | 13 | loadingchars=r"█▓▒░▒▓", # Last character of bar moving as bar loads (moves even if no progress) |
11 | | - startendchar=r"||", # Characters going around the bar |
| 14 | + startendchar=r"||", # The two characters going around the bar |
12 | 15 | barwidth=int(os.get_terminal_size().columns/2), # Length of the bar in characters (does not include what's around the bar) |
13 | 16 | displaypercentage=False, # Show percentage as well or not |
14 | 17 | displaycount=False # Show count as well or not |
15 | 18 | ): |
16 | 19 | self.pretext = str(pretext) |
17 | 20 | self.progresschar = str(progresschar) |
| 21 | + self.remainingbarchar = str(remainingbarchar) |
18 | 22 | self.loadingchars = loadingchars |
19 | 23 | self.startendchar = str(startendchar) |
20 | 24 | self.barwidth = int(barwidth) |
21 | 25 | self.displaypercentage = displaypercentage |
22 | 26 | self.displaycount = displaycount |
23 | 27 |
|
24 | | - # loadingchars ideas |
25 | | - # characters = "-/|\" |
26 | | - # characters = ["-_="] |
27 | | - |
28 | 28 | # Private |
29 | 29 | self.loadingcharsindex = 0 |
30 | 30 | self.firstprint = True |
@@ -87,7 +87,7 @@ def print(self,number,max): |
87 | 87 | self.loadingcharsindex = (self.loadingcharsindex+1) % len(self.loadingchars) |
88 | 88 | remainingbar -= 1 |
89 | 89 | #Add remaining gap |
90 | | - barstring += remainingbar*" " |
| 90 | + barstring += remainingbar*self.remainingbarchar |
91 | 91 | #End char |
92 | 92 | if self.startendchar: |
93 | 93 | if len(self.startendchar) >= 2: |
|
0 commit comments