Learn to Code via Tutorials on Repl.it!

← Back to all posts
Coloroma Tutorial [₱Ɏ₮ⱧØ₦]
JosephSanthosh (1194)

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

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

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('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
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

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

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!

MatthewXia (25)

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

JosephSanthosh (1194)

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

JosephSanthosh (1194)

Hey! Slack is working now i think. @poetaetoes

poetaetoes (287)

@JosephSanthosh we cant chat no more


JosephSanthosh (1194)

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

poetaetoes (287)


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

poetaetoes (287)

@JosephSanthosh maybe the dumb school blocked it

JosephSanthosh (1194)

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

poetaetoes (287)

@JosephSanthosh well ctrl r is refresh so yeah

JosephSanthosh (1194)

great! if this helped could u upvote? @poetaetoes

poetaetoes (287)

@poetaetoes i did something else to solve

JosephSanthosh (1194)

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

poetaetoes (287)

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

poetaetoes (287)

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

rediar (402)

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.

JosephSanthosh (1194)

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

DungeonMaster00 (149)

you can do the same and more with ansi sorry

DungeonMaster00 (149)

@DungeonMaster00 and it doesnt waste package time

DungeonMaster00 (149)

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

poetaetoes (287)

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

JosephSanthosh (1194)

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