progress icon indicating copy to clipboard operation
progress copied to clipboard

Does it work with jupyter lab?

Open tamkaho opened this issue 4 years ago • 3 comments

It doesn't seem to be showing on Jupyter lab for me. Is there a way to get it to work?

tamkaho avatar Jun 11 '20 16:06 tamkaho

Need to skip check_tty, also skip hide_cursor so not to print esc commands: example:

from progress.bar import Bar
with Bar(message='Prog', max=20, check_tty=False, hide_cursor=False) as bar:
    for _ in range(20):
        time.sleep(1)
        bar.next()
    bar.finish()  # prints an empty line, not necessary

Update: without hide_cursor=False there is no visible difference on screen but from source code it prints esc commands which are not necessary in Jupyter.

zhaowb avatar Jul 19 '20 20:07 zhaowb

Also jupyter seems need a chance to get '\r' right (got hint here) ~So use in jupyter better use a time.sleep(0) to let jupyter render '\r' right.~ Otherwise the output may corrupt for long runs.

Update: Sorry this doesn't really work. It might help in shorter runs, but in long runs (191783 in my test, update() every time) it's still ugly.

from progress.bar import Bar
with Bar(message='Prog', max=20, check_tty=False, hide_cursor=False) as bar:
    for _ in range(20):
        time.sleep(1)
        bar.next()
        time.sleep(0)   # <<< add this
    bar.finish()  # prints an empty line, not necessary

zhaowb avatar Oct 03 '20 06:10 zhaowb

The same issue stands using marimo, and the suggested fix works too

visika avatar Aug 08 '24 19:08 visika