Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

termcolor python

# To install termcolor
pip install termcolor
Comment

Python terminal colour

class Base:
    # Foreground:
    HEADER = '33[95m'
    OKBLUE = '33[94m'
    OKGREEN = '33[92m'
    WARNING = '33[93m'
    FAIL = '33[91m'
    # Formatting
    BOLD = '33[1m'
    UNDERLINE = '33[4m'    
    # End colored text
    END = '33[0m'
    NC ='x1b[0m' # No Color

class ANSI_Compatible:
    END = 'x1b[0m'
    # If Foreground is False that means color effect on Background
    def Color(ColorNo, Foreground=True): # 0 - 255
        FB_G = 38 # Effect on foreground
        if Foreground != True:
            FB_G = 48 # Effect on background
        return 'x1b[' + str(FB_G) + ';5;' + str(ColorNo) + 'm'

class Formatting:
    Bold = "x1b[1m"
    Dim = "x1b[2m"
    Italic = "x1b[3m"
    Underlined = "x1b[4m"
    Blink = "x1b[5m"
    Reverse = "x1b[7m"
    Hidden = "x1b[8m"
    # Reset part
    Reset = "x1b[0m"
    Reset_Bold = "x1b[21m"
    Reset_Dim = "x1b[22m"
    Reset_Italic = "x1b[23m"
    Reset_Underlined = "x1b[24"
    Reset_Blink = "x1b[25m"
    Reset_Reverse = "x1b[27m"
    Reset_Hidden = "x1b[28m"

class GColor: # Gnome supported
    END = "x1b[0m"
    # If Foreground is False that means color effect on Background
    def RGB(R, G, B, Foreground=True): # R: 0-255  ,  G: 0-255  ,  B: 0-255
        FB_G = 38 # Effect on foreground
        if Foreground != True:
            FB_G = 48 # Effect on background
        return "x1b[" + str(FB_G) + ";2;" + str(R) + ";" + str(G) + ";" + str(B) + "m"

class Color:
    # Foreground
    F_Default = "x1b[39m"
    F_Black = "x1b[30m"
    F_Red = "x1b[31m"
    F_Green = "x1b[32m"
    F_Yellow = "x1b[33m"
    F_Blue = "x1b[34m"
    F_Magenta = "x1b[35m"
    F_Cyan = "x1b[36m"
    F_LightGray = "x1b[37m"
    F_DarkGray = "x1b[90m"
    F_LightRed = "x1b[91m"
    F_LightGreen = "x1b[92m"
    F_LightYellow = "x1b[93m"
    F_LightBlue = "x1b[94m"
    F_LightMagenta = "x1b[95m"
    F_LightCyan = "x1b[96m"
    F_White = "x1b[97m"
    # Background
    B_Default = "x1b[49m"
    B_Black = "x1b[40m"
    B_Red = "x1b[41m"
    B_Green = "x1b[42m"
    B_Yellow = "x1b[43m"
    B_Blue = "x1b[44m"
    B_Magenta = "x1b[45m"
    B_Cyan = "x1b[46m"
    B_LightGray = "x1b[47m"
    B_DarkGray = "x1b[100m"
    B_LightRed = "x1b[101m"
    B_LightGreen = "x1b[102m"
    B_LightYellow = "x1b[103m"
    B_LightBlue = "x1b[104m"
    B_LightMagenta = "x1b[105m"
    B_LightCyan = "x1b[106m"
    B_White = "x1b[107m"
Comment

termcolor python

import termcolor
termcolor.cprint('This text is red!','red')
copied!
Comment

python colored text into terminal

print('x1b[38;2;5;86;243m' + 'Programiz' + 'x1b[0m')
Comment

PREVIOUS NEXT
Code Example
Python :: text xml 
Python :: conmbination in python 
Python :: youtube-dl python not found 
Python :: how to extract a list of values from numpy array using index list 
Python :: Python3: Deleting even and only showing uneven numbers from, set list. 
Python :: Python NumPy asfarray Function Syntax 
Python :: Python NumPy asscalar Function Example 01 
Python :: Python NumPy hstack Function Example with 2d array 
Python :: seaborn log heatmap 
Python :: Python NumPy insert Function Example Working with Scalars 
Python :: how to add to an exsiting value of an index in a list 
Python :: pandas dt.weekday to string 
Python :: Python how to use __ne__ 
Python :: python mxs Classof 
Python :: ignopre rankwarning pyton 
Python :: NumPy unpackbits Code Unpacked array along default axis 
Python :: main code for bpsk scheme 
Python :: cast set 
Python :: how to use python telegram filters 
Python :: raspberry pi set python 3 as default 
Python :: BeautifulSoup : Fetched all the links on a webpage how to navigate through them without selenium 
Python :: dnpy notify 
Python :: heatmap colorbar label 
Python :: python 3.9.7 
Python :: pandas drop zeros from series 
Python :: KeyError: 0 python 
Python :: install pythong to custom location 
Python :: delet categories from coco dataset 
Python :: How to Load Any HuggingFace Model in spaCy 
Python :: matplotlib doesnt show suptitle 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =