
Each object has its own set of constants that can be called in the print() function.īy appending these components in a human-friendly way, Colorama converts values like YELLOW to 43, for the Back object, RED to 31 for the Fore object, etc. We first import the functions: init() (to initialize the module and to set the autoreset to True so we don't have to reset it manually), Fore (Foreground text object), Back (Background Object) and Style (Style Object). Print(Style.BRIGHT + Back.YELLOW + Fore.RED + "CHEESY") This article focuses on the escape sequences to color text.ĭownload the eBook # colorama_demo.py from colorama import init, Fore, Back, Style The text is colored on your terminal based on ANSI Escape sequences.

Entering this character will print a new line in the output. A familiar example would be the \n character, which is a New Line sequence. These are special strings that modify the behavior of the terminal. How do we control the presentation of the data we're are outputting to the terminal? You may have seen command-line utilities with colorful text and progress bars. It can display a moving cursor, color the text, clear the entire screen, and much more than just static output. Your Teletypewriter (TTY), or rather your terminal, is not only capable of showing the output of a program.
#Eclipse change selected text color how to#
This article shows you how to print colored output in the terminal in Python with and without libraries.

In those cases, a dash of color could make a difference. There are always cases when we want to highlight output to the user, for example, a warning or error message. It's typical for CLI apps to return text in the same color of the terminal.
