Rockhopper-Technologies / enlighten

Enlighten Progress Bar for Python Console Apps
https://python-enlighten.readthedocs.io
Mozilla Public License 2.0
416 stars 25 forks source link

progress bar with fixed width #47

Closed masavini closed 2 years ago

masavini commented 2 years ago

hi, is it possible to set a Counter with a fixed width progress bar field? thanks!

avylove commented 2 years ago

I want to make sure I understand the ask. You want to set the length of the just the bar, but not set the length of the whole line? I'm imaging a use case where another field changes length, causing the bar to grow and shrink. But I'm wondering if it's better to pad the field instead. Do you have a different use case?

masavini commented 2 years ago

You want to set the length of the just the bar, but not set the length of the whole line?

exactly what i meant, thanks!

avylove commented 2 years ago

I'll have to think about it, I'm worried introducing a field like bar_width might be confusing. Ideally, it would be set as a formatting option, but that implementation gets a little more complicated. I think that's the route I'd prefer to take, but it will be a little while before I have time to dig into it.

This can be done indirectly today. The total width can be set manually and the width of all the other fields can be set as formatting options.

If you have a specific use case, that would be helpful.

masavini commented 2 years ago

hi, my use case is pretty simple: i have multiple counters which run pretty fast and having several progress bars with constantly changing width make them very hard to look at.

this is the bar format for all of the counters:

_B_FMT = '{desc}{desc_pad}{percentage:3.0f}%|{bar}|{count:4d}/{total:4d}' + ' @ {rate:.2f}{unit_pad}{unit}/s'

everything in this format has a fixed length except for the {bar} and the {rate} fields. If i could have a fixed width {bar} the overall readability would be greatly increased.

masavini commented 2 years ago

just read again your suggestion, and found out that the easiest solution was to set a fixed width for the {rate} field.

so i changed my bar format with {rate:6.2f}, set a fixed width for the whole bar and it works like a charm.

thanks for your help!

avylove commented 2 years ago

Awesome! Glad it worked out!