xxxxxxxxxx
import colorama
from colorama import Fore
print(Fore.RED + 'This text is red in color')
xxxxxxxxxx
import colorama
from colorama import Fore
print(Fore.RED + 'This text is red in color')
xxxxxxxxxx
from colorama import init
from colorama import Fore
init()
print(Fore.BLUE + 'Hello')
print(Fore.RED + 'Hello')
print(Fore.YELLOW + 'Hello')
print(Fore.GREEN + 'Hello')
print(Fore.WHITE + 'Hello')
#test in vscode
#code by fawlid
xxxxxxxxxx
#example
print("\033[1;31mHello World!\033[0m")
print("\033[<properties>;<color>m")
Black 30 No effect 0 Black 40
Red 31 Bold 1 Red 41
Green 32 Underline 2 Green 42
Yellow 33 Negative1 3 Yellow 43
Blue 34 Negative2 5 Blue 44
Purple 35 Purple 45
Cyan 36 Cyan 46
White 37 White 47
xxxxxxxxxx
class Foreground:
RESET = "\033[0m"
RED = "\033[38;2;255;0;0m"
REDORANGE = "\033[38;2;255;82;0m"
ORANGE = "\033[38;2;255;165;0m"
ORANGEYELLOW = "\033[38;2;255;210;0m"
YELLOW = "\033[38;2;255;255;0m"
YELLOWGREEN = "\033[38;2;180;255;0m"
GREEN = "\033[38;2;0;255;0m"
GREENBLUE = "\033[38;2;0;180;180m"
BLUE = "\033[38;2;0;0;255m"
BLUEPURPLE = "\033[38;2;75;0;202m"
PURPLE = "\033[38;2;150;0;150m"
BOLD = "\033[38;2;255;255;255;1m"
ITALIC = "\033[38;2;255;255;255;3m"
UNDERLINE = "\033[38;2;255;255;255;4m"
REVERSE = "\033[38;2;255;255;255;7m"
DIM = "\033[38;2;255;255;255;2m"
def _hextorgb(hexcode):
hexcode = str(hexcode)
if hexcode[0] == "#":
hexcode = hexcode[1:]
r, g, b = hexcode[0:2], hexcode[2:4], hexcode[4:6]
r, g, b = int(hex(int(r, 16)), 16), int(hex(int(g, 16)), 16), int(hex(int(b, 16)), 16)
return (r, g, b)
def customrgb(rgb):
r, g, b = rgb
return f"\033[38;2;{r};{g};{b}m"
def customhex(hexcode):
hexcode = str(hexcode)
if hexcode[0] == "#":
hexcode = hexcode[1:]
r, g, b = hexcode[0:2], hexcode[2:4], hexcode[4:6]
r, g, b = int(hex(int(r, 16)), 16), int(hex(int(g, 16)), 16), int(hex(int(b, 16)), 16)
return f"\033[38;2;{r};{g};{b}m"
class Background:
RESET = "\033[0m"
RED = "\033[48;2;255;0;0m"
REDORANGE = "\033[48;2;255;82;0m"
ORANGE = "\033[48;2;255;165;0m"
ORANGEYELLOW = "\033[48;2;255;210;0m"
YELLOW = "\033[48;2;255;255;0m"
YELLOWGREEN = "\033[48;2;180;255;0m"
GREEN = "\033[48;2;0;255;0m"
GREENBLUE = "\033[48;2;0;180;180m"
BLUE = "\033[48;2;0;0;255m"
BLUEPURPLE = "\033[48;2;75;0;202m"
PURPLE = "\033[48;2;150;0;150m"
REVERSE = "\033[48;2;255;255;255;7m"
def _hextorgb(hexcode):
hexcode = str(hexcode)
if hexcode[0] == "#":
hexcode = hexcode[1:]
r, g, b = hexcode[0:2], hexcode[2:4], hexcode[4:6]
r, g, b = int(hex(int(r, 16)), 16), int(hex(int(g, 16)), 16), int(hex(int(b, 16)), 16)
return (r, g, b)
def customrgb(rgb):
r, g, b = rgb
return f"\033[48;2;{r};{g};{b}m"
def customhex(hexcode):
hexcode = str(hexcode)
if hexcode[0] == "#":
hexcode = hexcode[1:]
r, g, b = hexcode[0:2], hexcode[2:4], hexcode[4:6]
r, g, b = int(hex(int(r, 16)), 16), int(hex(int(g, 16)), 16), int(hex(int(b, 16)), 16)
return f"\033[48;2;{r};{g};{b}m"
# Save this code in a file named colors.py
# Then in your code add an import
# to here
xxxxxxxxxx
from colorama import Fore, Back, Style
print(Fore.RED + "red")
print(Style.RESET_ALL)
xxxxxxxxxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
print("\033[0;37;40m Normal text\n")
print("\033[2;37;40m Underlined text\033[0;37;40m \n")
print("\033[1;37;40m Bright Colour\033[0;37;40m \n")
print("\033[3;37;40m Negative Colour\033[0;37;40m \n")
print("\033[5;37;40m Negative Colour\033[0;37;40m\n")
print("\033[1;37;40m \033[2;37:40m TextColour BlackBackground TextColour GreyBackground WhiteText ColouredBackground\033[0;37;40m\n")
print("\033[1;30;40m Dark Gray \033[0m 1;30;40m \033[0;30;47m Black \033[0m 0;30;47m \033[0;37;41m Black \033[0m 0;37;41m")
print("\033[1;31;40m Bright Red \033[0m 1;31;40m \033[0;31;47m Red \033[0m 0;31;47m \033[0;37;42m Black \033[0m 0;37;42m")
print("\033[1;32;40m Bright Green \033[0m 1;32;40m \033[0;32;47m Green \033[0m 0;32;47m \033[0;37;43m Black \033[0m 0;37;43m")
print("\033[1;33;40m Yellow \033[0m 1;33;40m \033[0;33;47m Brown \033[0m 0;33;47m \033[0;37;44m Black \033[0m 0;37;44m")
print("\033[1;34;40m Bright Blue \033[0m 1;34;40m \033[0;34;47m Blue \033[0m 0;34;47m \033[0;37;45m Black \033[0m 0;37;45m")
print("\033[1;35;40m Bright Magenta \033[0m 1;35;40m \033[0;35;47m Magenta \033[0m 0;35;47m \033[0;37;46m Black \033[0m 0;37;46m")
print("\033[1;36;40m Bright Cyan \033[0m 1;36;40m \033[0;36;47m Cyan \033[0m 0;36;47m \033[0;37;47m Black \033[0m 0;37;47m")
print("\033[1;37;40m White \033[0m 1;37;40m \033[0;37;40m Light Grey \033[0m 0;37;40m \033[0;37;48m Black \033[0m 0;37;48m")
\n")