Reputation: 1677
I have a group of progress bars and I use tqdm.write
to print log messages above them while they are running. For aesthetic reasons, I'd like to visually separate the log messages from the progress bars with an empty line or something like a repeated "=", like:
Log message 1
Log message 2
Log message 3
==================================================
Progress 1: 50%|█████████████████ |
Progress 2: 50%|█████████████████ |
Is there any way to achieve that?
Upvotes: 4
Views: 6500
Reputation: 1177
It's a bit of a hack, but the following might be a start for you:
from tqdm import tqdm
from tqdm._utils import _term_move_up
import time
pbar = tqdm(range(5))
border = "="*50
clear_border = _term_move_up() + "\r" + " "*len(border) + "\r"
for i in pbar:
pbar.write(clear_border + "Message %d" % i)
pbar.write(border)
pbar.update()
time.sleep(0.1)
Upvotes: 2