xxxxxxxxxx
# You can use colorama for changing the text color here is a example of that
from ast import For
from random import random
from random import randint
'''
First Install colorama by typing this in the terminal:
python -m pip install colorama or simply pip install colorama
'''
import colorama
from colorama import Fore,Back,Style
colorama.init(autoreset=True)
# Now here back is for background and Fore is for text color.
while(0<10):
eyt = input("Enter your text - ")
wcib= input("Enter your colour for back - ")
# wcib= wcib.upper()
wcif= input("Enter your colour for text - ")
# wcif= wcif.upper()
if(wcib == "black" and wcif == "red"):
print(Back.BLACK + Fore.RED + eyt)
if(wcib == "black" and wcif == "blue"):
print(Back.BLACK + Fore.BLUE + eyt)
else:
randoma=randint(1,6)
if(randoma == 1):
print(Back.BLACK+Fore.LIGHTGREEN_EX+"We are sorry we dont have that in our library")
if(randoma == 2):
print(Back.BLACK+Fore.LIGHTBLACK_EX+"We are sorry we dont have that in our library")
if(randoma == 3):
print(Back.BLACK+Fore.LIGHTCYAN_EX+"We are sorry we dont have that in our library")
if(randoma == 4):
print(Back.BLACK+Fore.LIGHTMAGENTA_EX+"We are sorry we dont have that in our library")
if(randoma == 5):
print(Back.BLACK+Fore.LIGHTRED_EX+"We are sorry we dont have that in our library")
if(randoma == 6):
print(Back.BLACK+Fore.LIGHTYELLOW_EX+"We are sorry we dont have that in our library")
'''
colors present -
Fore: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.
Back: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.
Style: DIM, NORMAL, BRIGHT, RESET_ALL
'''
xxxxxxxxxx
def colored(r, g, b, text):
return "\033[38;2;{};{};{}m{} \033[38;2;255;255;255m".format(r, g, b, text)
text = 'Hello, World'
colored_text = colored(255, 0, 0, text)
print(colored_text)
#or
print(colored(255, 0, 0, 'Hello, World'))
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
#install colorama module
from colorama import Fore
blue = Fore.BLUE
print(f"{blue} blue text")
xxxxxxxxxx
from termcolor import colored
print(colored('python', 'green', attrs=['bold']))
xxxxxxxxxx
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKCYAN = '\033[96m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
xxxxxxxxxx
'''
install chromaconsole by typing this in the terminal:
pip install chromaconsole
'''
from chromaconsole import Color, Style
print(f"{Color.text(r, g, b)}here is RGB colored text{Style.reset()}")
print(f"{Color.background(r, g, b)}here is RGB colored background{Style.reset()}")
print(f"{Color.text('#rrggbb')}here is HEX colored text{Style.reset()}")
print(f"{Color.background('#rrggbb')}here is HEX colored background{Style.reset()}")
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")