New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Width of progressbar is wrong #33
Comments
It could be due to an old version but there's not really a mistake (in my case at least).
While it looks weird, it's just adjusting to the width of the terminal (80 characters) and at the last line the I'll see if I can make those (mostly) fixed size to make it cleaner. |
Release 3.4.0 tries to make sure that the widgets always keep the same size. It won't work in all cases but many cases should be handled now. |
Now i do not get any progressbar at all. |
That means something is wrong with the width detection... I tested it in several environments and it appeared to work but apparently it's still broken :( Sorry about that, I'll have a look at it. |
And on windows I get: for from progressbar import ProgressBar
progress = ProgressBar() |
Oh, and I think you misunderstood: This is the exact output I posted. I did not mean, that the last progressbar is wider than the others. |
That would actually be the effect if the width can't be detected. The bar should automatically resize to the size of your screen. But if your screen is somehow 0 (broken detection code), it makes the bar as small as possible. Regardless, it's significantly broken unfortunately :( I've removed the release from pypi for the time being and I'll try to update the package soon. |
Using blessings.Terminal gives me the correct results. |
Just playing around a bit: from blessings import Terminal
from time import sleep
t = Terminal()
with t.hidden_cursor():
for i in range(101):
percentage = '{:>3d} %'.format(i)
start = '|'
end = '|'
barlength = t.width - (len(percentage) + len(start) + len(end))
len_progress = max(int(round(barlength * (i/100), 0)) - 1, 0)
bar = '=' * len_progress
arrow = '>' if i < 100 else '='
empty = ' ' * (barlength - len_progress - 1)
full = percentage + start + bar + arrow + empty + end
print('\r' + full, end='')
print(t.move_right(1) + t.clear_eos, end='', flush=True)
sleep(0.1) |
Blessings is a very nice module as well, I've added the module as a width detection option for people that have it installed but it still has some detection if it's not available |
Sorry for the trouble Max, I believe the current release should fix everything. |
Ah yes. I think you forgot a debug output:
An idea: |
Oops... indeed, it's gone now :) As for collapsing widgets, not impossible to achieve but I'm not sure how to implement that cleanly in the base code. Generally screens are fairly large these days but it's a bit of a waste of screenspace indeed. I've just pushed out a new release that has support for something along those lines. Give this code a try: import time
import progressbar
bar = progressbar.ProgressBar(widgets=[
progressbar.Timer(min_width=200),
progressbar.Bar(),
])
for i in bar(range(200)):
time.sleep(0.1) |
Note that the |
arch linux, i3wm, rxvt-unicode-256 color
Also on windows in mysy2
The text was updated successfully, but these errors were encountered: