Giter Site home page Giter Site logo

Comments (14)

wolph avatar wolph commented on May 19, 2024

It could be due to an old version but there's not really a mistake (in my case at least).

 10% (1 of 10) |##                          | Elapsed Time: 0:00:00 ETA: 0:00:00
 20% (2 of 10) |#####                       | Elapsed Time: 0:00:00 ETA: 0:00:00
 30% (3 of 10) |########                    | Elapsed Time: 0:00:00 ETA: 0:00:00
 40% (4 of 10) |###########                 | Elapsed Time: 0:00:00 ETA: 0:00:00
 50% (5 of 10) |##############              | Elapsed Time: 0:00:00 ETA: 0:00:00
 60% (6 of 10) |################            | Elapsed Time: 0:00:00 ETA: 0:00:00
 70% (7 of 10) |###################         | Elapsed Time: 0:00:00 ETA: 0:00:00
 80% (8 of 10) |######################      | Elapsed Time: 0:00:00 ETA: 0:00:00
 90% (9 of 10) |#########################   | Elapsed Time: 0:00:00 ETA: 0:00:00
100% (10 of 10) |#############################| Elapsed Time: 0:00:00 Time: 0.12

While it looks weird, it's just adjusting to the width of the terminal (80 characters) and at the last line the Time: 1.00 is less wide than the ETA: 0:00:0 which causes it to be wider. Also, the 10 of 10 is wider than 9 of 10 which causes it to move.

I'll see if I can make those (mostly) fixed size to make it cleaner.

from python-progressbar.

wolph avatar wolph commented on May 19, 2024

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.

from python-progressbar.

maxnoe avatar maxnoe commented on May 19, 2024

Now i do not get any progressbar at all.
100% (100 of 100) || Elapsed Time: 0:00:10 Time: 0:00:10-

from python-progressbar.

wolph avatar wolph commented on May 19, 2024

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.

from python-progressbar.

maxnoe avatar maxnoe commented on May 19, 2024

And on windows I get:
AttributeError: module 'signal' has no attribute 'SIGWINCH'

for

from progressbar import ProgressBar

progress = ProgressBar()

from python-progressbar.

maxnoe avatar maxnoe commented on May 19, 2024

Oh, and I think you misunderstood: This is the exact output I posted.
Every time the progressbar was updated a new line was started, because it was slidly wider (1 or a feq charakters) than the line width.

I did not mean, that the last progressbar is wider than the others.

from python-progressbar.

wolph avatar wolph commented on May 19, 2024

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.

from python-progressbar.

maxnoe avatar maxnoe commented on May 19, 2024

Using blessings.Terminal gives me the correct results.

from python-progressbar.

maxnoe avatar maxnoe commented on May 19, 2024

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)

from python-progressbar.

wolph avatar wolph commented on May 19, 2024

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

from python-progressbar.

wolph avatar wolph commented on May 19, 2024

Sorry for the trouble Max, I believe the current release should fix everything.

from python-progressbar.

maxnoe avatar maxnoe commented on May 19, 2024

Ah yes. I think you forgot a debug output:

shutil 48 111

An idea: Elapsed Time: ... takes very much space. Could you maybe reduce the number of widgets automatically if the term width is so small, that no progressbar fits any more? First dropping Elapsed Time, than the ETA?

from python-progressbar.

wolph avatar wolph commented on May 19, 2024

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)

from python-progressbar.

wolph avatar wolph commented on May 19, 2024

Note that the min_width and max_width settings indicate the width in characters, not pixels. So if the screen is at least 200 characters wide, the Timer will show.

from python-progressbar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.