[Python] TQDM progress bar, change text format

Discussão em 'Python' iniciado por Stack, Março 10, 2025.

  1. Stack

    Stack Membro Participativo

    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

    [​IMG]

    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

    [​IMG]

    Thanks for any help

    Continue reading...

Compartilhe esta Página