5 ms·
Lowbar – The simplest no-nonsense loading bar for Python
- loloquwowndueo 4y agoThis is nice if you have non-homogeneous tasks that need updating as different parts of the code are reached; for showing a progress bar when performing work on an iterable, tqdm seems simpler as it’s just one function call wrapping the iterable : https://pypi.org/project/tqdm/ https://pypi.org/project/tqdm/ Tqdm also has a “manual update” mode as a context manager, which looks comparable to lowbar.
- behnamoh 4y agotqdm also supports Jupyter Notebooks, which is really nice.
- drexlspivey 4y agoAnd it has no dependencies
- d0mine 4y agotqdm (Arabic word taqaddum — "progress") reminds Z'Ha'Dum from Babylon 5 https://youtu.be/jdoZvo8j6tc https://youtu.be/jdoZvo8j6tc
- carrotmoncher 4y agoThanks for the feedback! I was going for something different from already available loading bars, giving users maximum control while keeping the code base small.
- nomoreusernames 4y agoim getting into python this week after lots of years of doing other stuff and i appriciated how little code there was and how it was simple enough to get my head around quickly. thanks for sharing stranger.
- carrotmoncher 4y agoThis started as a quick little experiment with sys.stdout, but turned into something somewhat useful!
- melony 4y agoVery low bar, even pip is using the rich terminal library now (that's how you get all the RGB animations).
- carrotmoncher 4y agoMight be adding color support in the future :P
- chaostheory 4y agoThe big question is does it work with Pycharm?
- jwilk 4y agoWhy is that a big question?
- pacifika 4y agoThe terminals are considered non-interactive I believe.
- AnonymouX47 4y agoMeaning...?
- mattmerc 4y agoGreat job! Really cool solution here. I agree with the other comment that tqdm is simpler for iterables. Maybe see if you can abstract some of your logic to provide a wrapper function like tqdm does.
- carrotmoncher 4y agoThanks for the feedback! I was aiming for something different from other loading bars, even if it's a niche use case
- DanHulton 4y agoOne way in which it is not simple is that you can't set what the "max" of the bar is and have it auto-calculate the percentage. Like, if I have 7 tasks to accomplish, I have to manually keep track of the percentage to increase it by, and since 7 doesn't increase cleanly, I probably have to custom-code the final update to 100 manually, or it'll be just under or over, depending on how I round. Or maybe I have a variable number of tasks, and instead of increasing by a constant, I have to have separate variables for calculating the amount to increase by. 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.
- carrotmoncher 4y agoThe simplicity of this project isn't really in the usage, but the code base. I guess my main goal was to make a bar that was different from already available loading bars, and give as much control to the user as possible, while keeping the amount of code minimal. Thanks for the feedback though :D
- bobsmooth 4y agoYes, it's up to you to determine the progression of the program. You can keep track in fractions of 1 with casts and a bit of math.
- wildmanx 4y ago> since 7 doesn't increase cleanly, I probably have to custom-code the final update to 100 manually, 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.
- amelius 4y agoPerhaps you can use a prediction library such as Prophet (by Facebook) to predict the ETA.
- deleted 4y ago[deleted]
- ugh123 4y agolove it
- carrotmoncher 4y agoThanks for the feedback!
- hirebackenddev 4y ago
- bobsmooth 4y agoI think there's an issue somewhere. I was getting "AttributeError: module 'lowbar' has no attribute 'lowbar'. Did you mean: 'LowBar'?" until I changed "LowBar" to "lowbar" in lowbar.py using the example code. Looks great though!
- carrotmoncher 4y agothis issue has been fixed! thanks for the feedback :D
- jwilk 4y agohttps://github.com/AnnikaV9/lowbar/pull/1 https://github.com/AnnikaV9/lowbar/pull/1
- nine_k 4y agoI love it that such trivially simple piece of code can gain attention of HN at some moment, with reasonable critique in comments.
- carrotmoncher 4y agoyes! i did not expect it to get this much attention, since i thought no-one would find it useful due to easier to use bars like tqdm ;-;
- sammy2244 4y ago
- ottoflux 4y agoI love this. One tiny thought - perhaps use a conditional when setting the string percentage/completion value to prepend a 0 of it's < 10? 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.
- carrotmoncher 4y agoThis is a pretty good idea, thank you! I will implement this, but instead of a zero ill use a whitespace
- dangrie158 4y agoYou may want to use Format specifiers or fstrings (>py36) for a „more pythonic“ code. 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)
- carrotmoncher 4y agoits mostly for myself, i prefer to annotate variables so i can quickly know what type they should be when writing code (especially for bigger projects). I guess since lowbar is small, its pretty pointless, but its just a habit thats been stuck