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

Unwanted characters printing after bar.finish() #101

Open
AldoMaine opened this issue Mar 31, 2022 · 3 comments
Open

Unwanted characters printing after bar.finish() #101

AldoMaine opened this issue Mar 31, 2022 · 3 comments

Comments

@AldoMaine
Copy link

Windows 10, Python 3.9.7

Running this code:

`import random
import time
from progress.bar import Bar

def sleep():
t = 0.01
t += t * random.uniform(-0.1, 0.1) # Add some variance
time.sleep(t)

bar = Bar('Processing')
for i in bar.iter(range(200, 400)):
sleep()
bar.finish()`

Yields this in the console:
Processing |################################| 200/200
�[?25h

The last line is the unexpected output.

Investigation:
When finish() runs, it prints '\x1b[?25h' if hidden_cursor is True. On my system that results in the unwanted characters shown above. Probably a Windows thing?

Workaround: add bar._hidden_cursor = False before bar.finish()

@JadedHeart
Copy link

JadedHeart commented Nov 28, 2022

I have the same issue from time to time.

Windows 10, Python 3.10.5

@james-duvall
Copy link

james-duvall commented May 18, 2023

I had the same issue and I found a good solution in this stackoverflow post

Windows 10, Python 3.11.3

It seems that Windows does not really support the VT100 terminal escape codes. The Python cursor module implements a platform independent cursor hide/show. It uses the Windows API on Windows and the VT100 codes on Posix.

I just created a pull request (#109)

@mfebrizio
Copy link

The PR from @james-duvall fixes the issue and should be merged!

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

4 participants