Skip to content
← Back to Community
Coloroma Tutorial [₱Ɏ₮ⱧØ₦]
Profile icon
gibbsfreenergy

Coloroma is actually pretty cool! With coloroma you can print colored terminal text (words and backgrounds) on Python such as this:
image

I think coloroma is really simple and everyone should have a chance to learn so I'll be teaching coloroma in Python. [You can run the code below into the repl to see how it looks like!]

Step 1

Import coloroma
Copy-paste this:

from colorama import init init()

If you're not on a windows device init() will have no difference.

Step 2

So now you are using ANSI sequences to print color through coloroma!

from colorama import Fore, Back, Style print(Fore.RED + 'red color text') print(Back.BLUE + 'red text with BLUE background') print(Style.DIM + 'and in dim text') print(Style.RESET_ALL) print('back to normal now')

So you would want to add Fore.RED if you want the text to be red.
You would want to add Back.BLUE to make the text background blue!
And you can use the Style.DIM to dim the text.
Finally you can use Style.RESET_ALL to make it normal again.
You don't have to put these colors, you can put your own!
it's cool isn't it?

Optional Step 3

If you don't want the color to repeatedly you can send requests to turn off the color change, such as this:

from colorama import init init(autoreset=True) print(Fore.RED + 'some red text') print('automatically back to default color again')

So now it will print the first statement with color and not the second one!

Here are the ANSI sequences that coloroma converts:

ESC [ 0 m # reset all (colors and brightness) ESC [ 1 m # bright ESC [ 2 m # dim (looks same as normal brightness) ESC [ 22 m # normal brightness # FOREGROUND: ESC [ 30 m # black ESC [ 31 m # red ESC [ 32 m # green ESC [ 33 m # yellow ESC [ 34 m # blue ESC [ 35 m # magenta ESC [ 36 m # cyan ESC [ 37 m # white ESC [ 39 m # reset # BACKGROUND ESC [ 40 m # black ESC [ 41 m # red ESC [ 42 m # green ESC [ 43 m # yellow ESC [ 44 m # blue ESC [ 45 m # magenta ESC [ 46 m # cyan ESC [ 47 m # white ESC [ 49 m # reset # cursor positioning ESC [ y;x H # position cursor at x across, y down ESC [ y;x f # position cursor at x across, y down ESC [ n A # move cursor n lines up ESC [ n B # move cursor n lines down ESC [ n C # move cursor n characters forward ESC [ n D # move cursor n characters backward # clear the screen ESC [ mode J # clear the screen # clear the line ESC [ mode K # clear the line

If you have any questions or need help you can ask me :)

Hope you all like it!

Voters
Profile icon
biou
Profile icon
Leroy01010
Profile icon
MatthewXia
Profile icon
ANDREWVOSS
Profile icon
lightningrock
Profile icon
gibbsfreenergy
Comments
hotnewtop
Profile icon
MatthewXia

grats for 1000 cycles(sry im late) and nice tutorial

Profile icon
gibbsfreenergy

Oh thank you so much! That's rly kind of u. @MatthewXia

Profile icon
[deleted]

hey

Profile icon
gibbsfreenergy

Hey! Slack is working now i think. @poetaetoes

Profile icon
[deleted]

@JosephSanthosh not yet 😭

Profile icon
[deleted]

@JosephSanthosh we cant chat no more

privatly

Profile icon
[deleted]

@JosephSanthosh this doesnt work

Profile icon
gibbsfreenergy

It works! I can access it and message u! U shud refresh it! @poetaetoes

Profile icon
[deleted]

@JosephSanthosh

bro, i spammed the ctrl+r key 100 times a minute so yeah

Profile icon
[deleted]

@JosephSanthosh maybe the dumb school blocked it

Profile icon
gibbsfreenergy

well its a good thing im on a mac and ctrl is useless. try refreshing, please upvote if this helped. @poetaetoes

Profile icon
gibbsfreenergy

do you have any other device
@poetaetoes

Profile icon
[deleted]

@JosephSanthosh yes but only for zoom 😟

Profile icon
[deleted]

@JosephSanthosh well ctrl r is refresh so yeah

Profile icon
[deleted]

@JosephSanthosh still nut working

Profile icon
[deleted]

@JosephSanthosh

YEAH GOT IT

Profile icon
gibbsfreenergy

great! if this helped could u upvote? @poetaetoes

Profile icon
[deleted]

@JosephSanthosh

NO AND COME TO SLACK

Profile icon
[deleted]

@poetaetoes i did something else to solve

Profile icon
gibbsfreenergy

ok, upvote? @poetaetoes

Profile icon
[deleted]
Profile icon
gibbsfreenergy

i meant the post, but nvm, uhh, thanks :) @poetaetoes

Profile icon
gibbsfreenergy

who is gerald busstop? @poetaetoes

Profile icon
[deleted]

@JosephSanthosh its a joke that i made with some of my classmates

Profile icon
gibbsfreenergy

oh cool! @poetaetoes

Profile icon
[deleted]

@JosephSanthosh hey u online atm? come to slack if so

Profile icon
johnnyfrancis

"Unidentifed Name: Fore" How to fix it?

Profile icon
Leroy01010

NOICE

Profile icon
gibbsfreenergy
Profile icon
Leroy01010
Profile icon
Leroy01010

hey how did u do the title txt @JosephSanthosh

Profile icon
gibbsfreenergy

HAHA, go to lingojam.com and us one of the text generators, then just copy paste. @Leroy01010

Profile icon
Leroy01010

o̶̧̨̲̖̰̬̜͉͕̎̿̽̓̀̀͘͜ͅķ̷̞̹͎̩̣̻͕̌̄̍͊̎̈́͌̎̀̓̕͝͝ ̷̨̧̝̞̹͈̼̱͔͚̜̺͇̺̪̏̋͂͌̄͂́̽̂̎̈̀͌̕͠t̷̡̛̛͉͕̤̞͓̲̰͛̀̇̋͊̓͌ḩ̴̢̛̮̭̖͖̥̥̖̎̄̇̉̍̎͛̒̌͛x̸̣̆́̾͊̔̆̌̚͜ @JosephSanthosh

Profile icon
rediar

Colorama sucks, it is bloat and slows down your project runtime. Use regular ANSI sequences like a normal person. Don't use modules for everything.

Profile icon
gibbsfreenergy
Profile icon
gibbsfreenergy

if you liked this post then please upvote ;) haha lol! @rediar

Profile icon
[deleted]

hey go to slack

Profile icon
[deleted]

hello u online at 2:30?

If ya are come to slack

Profile icon
gibbsfreenergy
Profile icon
[deleted]
Profile icon
[deleted]

@JosephSanthosh get to slacky

Profile icon
DungeonMaster00

you can do the same and more with ansi sorry

Profile icon
DungeonMaster00

@DungeonMaster00 and it doesnt waste package time

Profile icon
gibbsfreenergy

so should i do one about ansi? @DungeonMaster00

Profile icon
DungeonMaster00

@JosephSanthosh there are many online guides so dont worry about it

Profile icon
[deleted]

Nice!! Love it. Hope i will use it soon!

Profile icon
gibbsfreenergy

Hope you do! Leave an upvote if it helped. :) @poetaetoes