Skip to content
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

print statements between progress bars begin at the end of the progress bar line #162

Closed
jasonslay opened this issue Apr 11, 2018 · 2 comments

Comments

@jasonslay
Copy link

jasonslay commented Apr 11, 2018

Description

When using redirect_stdout=True, printing between progress bars begins printing at the end of the line the progress bar was on. In the example below the 'halftime' appears on the end of the line from the first progress bar (and is forced to wrap after the first character). I would expect it to start on a new line. Is this not the case?

Code

import time
import progressbar

for ix in progressbar.progressbar(range(5), redirect_stdout=True):
    print('first', ix)
    time.sleep(0.02)

print('halftime')

for ix in progressbar.progressbar(range(5), redirect_stdout=True):
    print('second', ix)
    time.sleep(0.02)

Output

first 0
first 1
first 2
first 3
first 4
100% (5 of 5) |#################| Elapsed Time: 0:00:00 Time:  0:00:00halftime
second 0
second 1
second 2
second 3
second 4
100% (5 of 5) |#################| Elapsed Time: 0:00:00 Time:  0:00:00

Versions

  • Python version: 3.6.5 (default, Mar 30 2018, 06:41:53)
  • Python distribution/environment: CPython
  • Operating System: MacOS 10.13.4
  • Package version: 3.37.0
@wolph wolph closed this as completed in 7257c76 Apr 11, 2018
@wolph
Copy link
Owner

wolph commented Apr 11, 2018

You're right, that's a bug. I've pushed a fix to development, can you test to make sure it works for you?

The odd thing is that it shouldn't be visible in most cases because the progressbar should be the same width as your terminal which means your terminal will auto-wrap it to the next line anyhow.

@jasonslay
Copy link
Author

7257c76 Fixes this bug for me! Thanks!

wolph added a commit that referenced this issue Apr 12, 2018
making sure we run all the finish code. fixes #162 v3.37.1

# gpg: Signature made Thu Apr 12 02:31:01 2018 CEST
# gpg:                using RSA key 149325FD15904E9C4EB89E95E81444E9CE1F695D
# gpg: Good signature from "Rick van Hattem <wolph@wol.ph>" [ultimate]
# gpg:                 aka "[jpeg image of size 9662]" [ultimate]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants