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

Progress bar not clearing line in Console mode #106

Open
ucohen opened this issue Feb 18, 2024 · 0 comments
Open

Progress bar not clearing line in Console mode #106

ucohen opened this issue Feb 18, 2024 · 0 comments

Comments

@ucohen
Copy link

ucohen commented Feb 18, 2024

In console mode, when adding a progress comment, the previous line is not completely cleared thus causing the leftover ending to remain. for example:

from fastprogress import progress_bar
from pathlib import Path
import time

files = list(Path('/etc').glob('*'))
pb = progress_bar(files)

for fn in pb:
    pb.comment = f'{fn.stem}'
    time.sleep(0.1)

console output:

|█████████████----| 77.69% [188/242 00:18<00:05 login]es]]e]te].conf]

I managed to root-cause the issue and solved it by updating on_update and padding with empty spaces to max_len

modify:

if len(to_write) > self.max_len: self.max_len=len(to_write)

to

if len(to_write) > self.max_len: self.max_len=len(to_write)
else: to_write += ' ' * (self.max_len - len(to_write))

is this the proper way to fix it?

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

1 participant