gipert / progressbar

An embarassingly simple progress bar for C++ loops
MIT License
215 stars 33 forks source link

Jupyter notebook #5

Open PietropaoloFrisoni opened 2 years ago

PietropaoloFrisoni commented 2 years ago

Hello,

is there a way in order to make this nicely compatible with jupyter notebook?

I am calling some C++ functions from jupyter with python and in the terminal the progress bar is displayed nicely, but on the terminal the result is very strange (see pictures).

Is there an "easy" way to solve this?

Thank you and congratulations! ju_comp term_comp

PietropaoloFrisoni commented 2 years ago

edit: the statement above of course should be: "in the (shell) terminal the progress bar is displayed nicely, but in the jupyter cell the result is very strange"

gipert commented 2 years ago

Hi Pietropaolo, unfortunately I don't use Jupyter notebooks myself. I'm afraid I cannot help you... If you discover something, a pull request would be highly appreciated. Thanks for reporting and good luck.

xloem commented 2 years ago

I'm guessing that this request comes from experience with https://github.com/tqdm/tqdm , which is well-used in both python and jupyter notebooks, and has produced a common culture of attaching a progress meter to everything. I came here from tqdm.

I looked into tqdm's source code, and unfortunately it appears to craft progress meters for jupyter notebook using html and calls out to the ipython backend to display the html as python objects. This is harder to do from a subprocess written in C++, because the ipython environment with its various variables is not present.

There's information on the communications protocol at for example https://jupyter-client.readthedocs.io/en/stable/messaging.html ; however, I think it might make more sense for the changes here to happen in python, which already has direct access to ipython, using some way to process the terminal formatting characters.

For example, this already exists: https://github.com/adamj9431/notebook_xterm