Jun 24, 2013 09:48 PM
(This post was last modified: Jun 24, 2013 09:49 PM by Hydra_.)
[img]http://s4.postimage.org/5ftaj2zrb/Hello_HF_2_copy.png[/img]
Colorama is a pretty cool module for making colorful text in your console application, imagine your console with colors, it would be GREAT 😅 for example check the pictures of some of my programs with those colors
Console Applications (Click to View)
Many people like my programs console with those colors, like Rhyno and Catalyst .. and I appreciate that 🤝
So, How to do such beautiful console?
Download colorama module
First of all we have to download the module. You can get the module from the following link: Download
Get started
Colorama let u control of the Foreground, Background and the Style of the text, but to start controlling all of these we have to import and initiate it:
Code
from colorama import *
init()As I told u before there are three basic controls for the text, the color, the background and the style. To manage the colors of text we use the following:
Code
Fore.REDCode
Back.REDColorama supports the following colors
- RED
- WHITE
- BLACK
- GREEN
- YELLOW
- BLUE
- MAGENTA
- CYAN
So let's see an example, the following example will print python in RED, then it would print it in WHITE and the background in RED.
Example#1 (Click to View)
But these colors are some kinda dark, let's lighten them and make them BRIGHT and to do that we use:
Code
Style.BRIGHTAs we noticed the 'python' word are bright now in the two lines. ;)
But what if we want to brighten just the line which Style.BRIGHT would be written in?!
Okay, at the of the script we initiate colorama by typing init() and notice it took no parameters, but to brighten one line we would set a parameter in init() called autoreset and we would set True as a value forr it.
Code
init(autoreset=True)Can u see the difference now, the first line is bright and the second one is dark, so if you initiated the script with the autoreset as True, and you want some lines in BRIGHT, you would have to write Style.BRIGHT at the first of each of those lines.
Now if we want to reset the foreground color we use:
Code
Fore.RESETCode
Back.RESETCode
Style.RESET_ALLBy this line you have just finished the basic stuff of colorama module to make wonderful colorful console applications, go and try it and start making your own colorful apps. For more info you can check the official page of colorama module.
If you need any help with colorama or anything in python, Feel free to PM me.
Thanks for reading.
||
||
||
\__/
\_/
\/
Thanks for reading.
||
||
||
\__/
\_/
\/


![[Image: 544062_320100448090931_790386392_n.png]](https://fbcdn-sphotos-a-a.akamaihd.net/hphotos-ak-prn1/544062_320100448090931_790386392_n.png)