Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python change Tqdm bar style

Tags:

python

tqdm

Is it possible to change the tqdm bar from

[Step 1]: 100%|███████████████████████████  | 109/109 [00:03<00:00, 32.46it/s]

to something like

[Step 1]: 100%[==========================>  ] 109/109 [00:03<00:00, 32.46it/s]
like image 894
Noa Be Avatar asked Jul 10 '26 16:07

Noa Be


1 Answers

for i in range tqdm(<iterator>, total=<>, ascii=' >='):
    <your code here>

This should do the trick, the ascii argument, reads the first character is the fill character, that is space here, you can use some other character like ascii="░▒█" and the bar would look like

0%[░░░░░░░░░░░░░░░░░░░░░]

The last character is the character which it fills when the progress bar has progressed a certain amount like

30%[███████░░░░░░░░░░░░░░]

While any character you put in between will be to fill while it is progressing, like say while it moves from 30% to 40%.

35%[███████▒░░░░░░░░░░░░░]

I hope that explains your question, you can have multiple progressing characters in the middle, like

ascii=" ▖▘▝▗▚▞█"

Try this one out, it is real fun to watch this progress, provided your console supports all the Unicode characters.

like image 195
scsanty Avatar answered Jul 13 '26 17:07

scsanty