Lowbar – The simplest no-nonsense loading bar for Python
github.com
github.com
Tqdm also has a “manual update” mode as a context manager, which looks comparable to lowbar.
I know every feature added to something simple adds unforeseen levels of complexity, but this choice doesn't eliminate complexity, it just moves the complexity to calling code, and for nearly every use case.
What do you mean with "not cleanly"?
bar.update_smooth(i * 100 / 7)
Once i is 7, this will be equal to 100. No matter your rounding mode. You don't need a CS degree for that formula.
For example, recursively enumerating the contents a file system interleaves increasing y (when subfolders are visited and unprocessed files and unvisited subfolders are found) with increasing x (when files and folders are processed/visited). At the end x catches up with y.
Lowbar could be easily adapted to a percentage-free style without backwards incompatibilities: the constructor could have a parameter, range with default 100, and new methods update_range() and update_range_smooth() could update y similarly to how update() and update_smooth() update x.
Looks great though!
like: completion_string: str = '0' + str(self.completion) if self.completion < 10 else str(self.completion)
basically it would keep your bar from shifting when percentage goes from single digit to double digit.
Also why do you annotate every variable, even if the type can be deduced automatically? That’s going to be a real PITA if you want to refactor the code e.g to support floats instead of ints any time in the future (in this case it’s probably just a hypothetical problem)