Найти в Дзене

Colored progressbar python console

Исходник, имитации загрузки цветной загрузки в консоль, видео работы. Необходимо установить библиотеку: pip install colored Исходник: import ctypes from termcolor import colored kernel32 = ctypes.windll.kernel32 kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7) import time print ('....Запуск....') progressbar =["▒▒▒▒▒▒▒▒▒▒", #0-10%[0] "█▒▒▒▒▒▒▒▒▒", #10-20%[1] "██▒▒▒▒▒▒▒▒", #20-30%[2] "███▒▒▒▒▒▒▒", #30-40%[3] "████▒▒▒▒▒▒", #40-50%[4] "█████▒▒▒▒▒", #50-60%[5] "██████▒▒▒▒", #60-704[6] "███████▒▒▒", #70-80%[7] "████████▒▒", #80-90%[8] "█████████▒", #90-99%[9] "██████████"] for i in range(101): time.sleep(0.1) if i <10: print('\r',colored(progressbar[0],'blue'), str(i),"%",end='') if 10 <i <20: print('\r',colored(progressbar[1],'green'), str(i),"%",end='') if 20 <i <30: print('\r',colored(progressbar[2],'yellow'), str(i),"%",end='') if 30 <i <40: print('\r',colored(progressbar[3],'blue'), str(i),"%",end='') if 40 <i <50: print('\r',col
Цветная имитация загрузки в коносоль.
Цветная имитация загрузки в коносоль.

Исходник, имитации загрузки цветной загрузки в консоль, видео работы.

Необходимо установить библиотеку:

pip install colored

Исходник:

import ctypes

from termcolor import colored

kernel32 = ctypes.windll.kernel32

kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)

import time

print ('....Запуск....')

progressbar =["▒▒▒▒▒▒▒▒▒▒", #0-10%[0]

"█▒▒▒▒▒▒▒▒▒", #10-20%[1]

"██▒▒▒▒▒▒▒▒", #20-30%[2]

"███▒▒▒▒▒▒▒", #30-40%[3]

"████▒▒▒▒▒▒", #40-50%[4]

"█████▒▒▒▒▒", #50-60%[5]

"██████▒▒▒▒", #60-704[6]

"███████▒▒▒", #70-80%[7]

"████████▒▒", #80-90%[8]

"█████████▒", #90-99%[9]

"██████████"]

for i in range(101):

time.sleep(0.1)

if i <10:

print('\r',colored(progressbar[0],'blue'), str(i),"%",end='')

if 10 <i <20:

print('\r',colored(progressbar[1],'green'), str(i),"%",end='')

if 20 <i <30:

print('\r',colored(progressbar[2],'yellow'), str(i),"%",end='')

if 30 <i <40:

print('\r',colored(progressbar[3],'blue'), str(i),"%",end='')

if 40 <i <50:

print('\r',colored(progressbar[4],'cyan'), str(i),"%",end='')

if 50 <i <60:

print('\r',colored(progressbar[5],'red'), str(i),"%",end='')

if 60 <i <70:

print('\r',colored(progressbar[6],'cyan'), str(i),"%",end='')

if 70 <i <80:

print('\r',colored(progressbar[7],'green'), str(i),"%",end='')

if 80 <i <90:

print('\r',colored(progressbar[8],'blue'), str(i),"%",end='')

if 90 <i <100:

print('\r',colored(progressbar[9],'blue'), str(i),"%",end='')

if i==100:

print('\r',colored(progressbar[10],'yellow'), str(i),"%",end='')

input(colored('\nЗагрузка завершена','red'))