The colorama
module (version 0.3.6
) allows us to easily create colored terminal text. We are going to use this to highlight good and bad events to the user. For example, when a plugin completes without errors, we display that with a green font. Similarly, when an error is encountered, we will print that in red.
Traditionally, printing colored text to the terminal is achieved by a series of escape characters on Linux or OS X systems. This, however, will not work for Windows operating systems. The following are examples of ANSI escape characters being used to create colored text in Linux or OS X terminals.
The color format is the "escape" character,\033
, followed by an open bracket and then the desired color code. We can change the background color in addition to the foreground color and even do both at the same time by separating the codes with a semicolon. The color code, 31m
, sets the foreground text to red. The color code, 47m
, sets the background to white. Notice in the second...