16 lines
544 B
Python
16 lines
544 B
Python
|
def show_progbar(done, total, msg=''):
|
||
|
total_blocks = 10
|
||
|
blocks_done = (done * total_blocks) // total
|
||
|
blocks_to_go = total_blocks - blocks_done
|
||
|
|
||
|
print('\r\x1b[K' # Go to the start of the line
|
||
|
'\x1b[0m' # Restart the "style"
|
||
|
'|' # Put the first "|"
|
||
|
+ blocks_done * '█' # Completed blocks
|
||
|
+ blocks_to_go * ' ' # Uncompleted blocks
|
||
|
+ '\x1b[7m|\x1b[0m' # End the bar
|
||
|
+ ' '
|
||
|
+ msg # Add message
|
||
|
+ '\r' # Go back to the start
|
||
|
, end='')
|