1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
from __future__ import unicode_literals, print_function from ctypes import windll, c_ulong
HANDLER = windll.Kernel32.GetStdHandle(c_ulong(0xfffffff5)) COLOR_MAPS = dict( black=0, blue=9, dark_blue=1, dark_green=2, dark_navy=3, dark_purple=5, dark_red=4, dark_white=7, dark_yellow=6, default=7, gray=8, green=10, navy=11, purple=13, red=12, white=15, yellow=14, )
def set_color(color="default"): windll.Kernel32.SetConsoleTextAttribute( HANDLER, COLOR_MAPS.get(color, 7) )
def show_text(text, color="default", new_line=True): set_color(color) print("{}{}".format(text, "\n" if new_line else "), end=") set_color()
show_text("yellow", color="yellow")
|