Closed diogomreiras closed 4 years ago
According to this there could be a end_line
problem.
They seem to suggest that the end of line should be ""
and not "\r"
.
I used the above example printProgressBar()
using the suggested change and it works fine on PyCharm and Terminal.
If there would be a manual way to change the line ending for the alive-bar
, then I could test if myself, but I found none.
Hello @diogomreiras,
I can't reproduce your problem, it does work properly on Pycharm:
I didn't do anything more than configuring a Python Interpreter with alive-progress
1.5.1 installed, and pasted your exact code. It does work. I'm also on a MacOS 10.15.5 using Pycharm:
The only difference seems to be Python version, which I've used 3.7.6, but this would not make that difference.
Regarding the end_line, that is an implementation detail, necessary to create animations, \r
is mandatory to enable printing on top of the same text very fast, to give the impression of moving things.
Anyway, keep me posted, let's try to figure this out.
Oh, regarding the terminal, in there it should work! Do you use iTerm2? If not I recommend it very much, it is much more advanced.
Anyway, the bar only soft wraps if there's no space for a full line, the terminal wraps automatically. Try to increase the Terminal a little.
Another thing, you could pass length=20
to decrease the alive_bar
size.
Regarding the animated gifs, yeah, pypi doesn't fit them. Please always use the main page in: https://github.com/rsalmei/alive-progress The pypi page is only updated on releases, and the main page gets updated much more regularly.
@rsalmei Thanks for your reply. I can run it correctly as you did on the Python Console of PyCharm, and on the normal Terminal outside of PyCharm. However on the Terminal outside of PyCharm it only behaves normally if the window size is larger then 80 char and the default is 80 wide (80x24 to be exact). So fails by 1 char since the eta uses 2 digits on the beginning.
However, running the file through the PyCharm option "Run 'main'" (right clicking on the file inside PyCharm) (I don't know how to describe it better!), where main.py
is a file with the previous code, then PyCharm's Run tab (next to Python Console tab) still has the behaviour I described before.
Hey, you can configure globally for the alive_bar
to be smaller, use:
from alive_progress import config_handler
config_handler.set_global(length=20)
What does that Pycharm's "Run 'main'" function do differently? Why wouldn't it work in there?
@rsalmei :
What does that Pycharm's "Run 'main'" function do differently? Why wouldn't it work in there?
I am no PyCharm expert. I have no idea... Is there anything I can do to help you somehow fix this?
I can run it correctly as you did on the Python Console of PyCharm, and on the normal Terminal outside of PyCharm.
So it does work in both pycharm and terminal, great. It is not working only via "Run main" function, I'm gonna try to simulate that.
Well, I know the pycharm's terminal is heavily instrumented, so maybe it is a bug in there.
I've tested, the "Run" command only calls python main.py
. The script works if you run it in the terminal, in the same working directory, but it does not work inside pycharm's. I think we can't do anything about it, just please use it inside pycharm's terminal or in a real terminal.
Regarding the size that soft wraps, please include a length
config in alive_bar
params for now to reduce it a little. The next release should eventually include a new feature to improve upon that, I'm working on it.
I just came across your tool and was also having issues running in PyCharm's "Run Console". I was able to get it to work using the answer here: https://stackoverflow.com/a/48002833/7658632
with alive_bar(row_num, force_tty=True, bar='filling') as bar:
I hope this helps!
Yes, thanks @darkhark I wasn't aware of that "Emulate terminal..." option! 👍
Indeed @darkhark , force_tty=True
was the magic sauce for PyCharm (2021.1) - cheers!
Tried to run your simplified example (below) and the bar does now work properly. Working with PyCharm2020.1.2 on a macOS 10.15.5 with Python3.7.3 using an new empty project and installing alive-progress as suggested on PyPi The bar only shows itself already completed after the 10s, so no progress is shown.
I also tried running this code from Terminal. The result is that it shows and updates the bar apparently correctly a few times (3 bars going up and down work fine during the 0/10 progress) but as soon as 1/10 progress is reached by the output of the bar, it prints a bar in a new line for every update...
Am I doing something wrong? :innocent: Let me know if you need more info. Hopefully we can get this beautiful took working for me 2 :muscle:
PS: the gifs on PyPi for the Styles section are not being shown, with a message of size being too big ; )