rsalmei / alive-progress

A new kind of Progress Bar, with real-time throughput, ETA, and very cool animations!
MIT License
5.53k stars 206 forks source link

A new line gets printed instead of updating the current line / Weird characters get printed #61

Closed Kovinda closed 3 years ago

Kovinda commented 3 years ago

Hi, Great library you've got. I started using it because I love the cool features

I just started working with alive-progress and tested it using the following script:

import time
items = range(10)                  # retrieve your set of items
with alive_bar(len(items)) as bar:   # declare your expected total
    for item in items:               # iterate as usual
        # process each item
        bar()                        # call after consuming one item
        time.sleep(1)

The output I get is : Screenshot 2020-12-05 165126

python prints the progress bar to a new line instead of updating the current line Also notice how some characters are like ? (question marks) inside boxes (I'm guessing something wrong with character encoding ??)

I'm using Python 3.8.3 on Windows 10 build 19041.630 The console I'm using is the windows command prompt The font used in the console is Consolas If you want more info, I'm willing to provide. Thank You !!

rsalmei commented 3 years ago

Hey man, thank you! I wish you like it even more after it start working right for you!

Well, it seems there's two problems in there. The new line I've found recently it does occur on Windows, only inside the basic python interpreter. Unfortunately, all function calls inside python on Windows prints its result on screen!! Argh 😞 That's why the lines all start with "on N: N", it's the current line that python interpreter arbitrarily prints...

So please try it inside ipython, it's a way better environment anyway (I use it 100% of the time):

pip install ipython
ipython

The new version in the works (#51) will not return the current line, so it should fix that.

The other problem is the weird characters. Unfortunately I think the basic command prompt on Windows really does not support them. They are control chars that I use to improve presentation like clearing the line, hiding the cursor, etc. For this I recommend installing the new WSL - Windows Subsystem for Linux. I've installed it on my gaming machine with Windows 10 Home Edition, and it's awesome! With it you get to use a very improved terminal app, with a much better shell like ZSH.

Kovinda commented 3 years ago

Thanks for the quick reply. I will try what you've recommended. Thanks again !! @rsalmei

blankdvth commented 3 years ago

Hi, even while using ipython it seems to display quite strangely, although it does seem to not have the newline issue anymore.

TheTechRobo commented 3 years ago

@BLANK-TH That seems like it's because your font doesn't have specific characters. (The [?], mario style item box :P )

not sure why the ^2K appears.

blankdvth commented 3 years ago

Yeah, that would make sense. It seems to happen with tqdm as well. I wonder what's missing. Maybe a half bar/quarter bar thing?

Looks extremely likely that it's a unicode character that's missing, with tqdm, specifying to use ASCII instead of Unicode seems to stop the issue, so it probably has to do with a missing unicode character.

Aside from using ASCII instead of the fancy unicode bars (as well as WSL), would there be any other fix for this? Something like the pip progress bar seems to work fine on all operating systems.

It seems many of the other animations have this issue as well, but some don't. Most of the showbars don't have this issue either.

rsalmei commented 3 years ago

Yeah, it does seem your font is missing quite a few characters, thank you @TheTechRobo . Here you could then use some of the spinners and bars that does not render those missing ones. Or just use theme=ascii, to get plain text all around.

rsalmei commented 3 years ago

Hey, great news! I just fixed the newline problem in #70, it will work as expected in python console too!

Kovinda commented 3 years ago

Can anyone mention a font to use with this ?

rsalmei commented 3 years ago

I strongly recommend any of the nerd-fonts! I use them for both terminal and coding.

blankdvth commented 3 years ago

Oooo, looks interesting, I'mma check that out.

EDIT: Doesn't seem to fix the missing font issue. Nevermind, setting wasn't applied correctly on windows, I fixed it.

EDIT 2: Doesn't seem to work on ConEmu but does work in native command prompt.

rsalmei commented 3 years ago

Yeah, it may be a limitation of the terminal itself. Please try on the new windows terminal: https://www.howtogeek.com/673729/heres-why-the-new-windows-10-terminal-is-amazing/

rsalmei commented 3 years ago

This issue feels resolved. Closing it, but feel free to contact me if anything arises.