I'm trying to display a progress bar in a jupyter notebook with a bold description preceding the bar.
for i in tqdm(range(10), desc='\x1b[1mglobal progress'):
time.sleep(.2)
seems to produce
I tried different options, qqdm and rich seem to work, but the former is stuck to 4 years ago, the latter seems to have a little too much overhead.
Following the comments I did this:
for i in tqdm(range(10), desc=tqdm.write('\x1b[1m global progress', end="")):
time.sleep(.2)
which renders the text in bold, but introduces an unwanted newline. The end=""
argument does not seem to have any effect. Actually I have exactly the same result if I use the built-in print
function
Thanks for any help
For those wanting to use this with tqdm.notebook
- the Jupyter Notebook progressbar decorator for iterators, you'll need both tqdm and ipywidgets installed, then try:
from tqdm.notebook import tqdm
import time
for i in tqdm(range(5), desc='𝐁𝐨𝐥𝐝 𝐃𝐞𝐬𝐜𝐫'):
time.sleep(.4)
That is based on a work-around for the widgets-based version that relies on the description accepting unicode; it is discussed here. For more details, see 'Tqdm progress bar bold description in jupyterlab' here at the Jupyter Discourse Forum.
There is also a version that works in JupyterLite at this time offered there.