Python Forum
Adding colour to Python console
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding colour to Python console
#1
Hello guys,

I tried to colourise the texts in a Python consol applications but the results were a little bit weird.

Firstly, I googled the whole thing and I discovered the ANSI codes. For example, take a look at the following code.

print("\033[0;37;40m Normal text\n")
print("\033[2;37;40m Underlined text\033[0;37;40m \n")
print("\033[1;37;40m Bright Colour\033[0;37;40m \n")
print("\033[3;37;40m Negative Colour\033[0;37;40m \n")
print("\033[5;37;40m Negative Colour\033[0;37;40m\n")
This code is not part of my project, just to let you know what I did. I utlised these stuff in my code but the console remained with black background and white (or light grey) font colour. The funny thing is that in the Jupyter window the ANSI colour codes did work.
Reply
#2
this will work if your terminal support ANSI code.
On windows - look at colorama, or termcolor (colorama is wrapper around termcolor)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
So I need an addon, right?
I hope it can work with Jupyter.
Reply
#4
it's a package. Like any other package in python. I don't use Jupyter, so someone else would tell. There might be other solutions in Jupyter
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
(Apr-10-2020, 12:57 PM)Archangelos Wrote: Hello guys,

I tried to colourise the texts in a Python consol applications but the results were a little bit weird.
Hi!

Maybe this can give you some ideas:

https://python-forum.io/Thread-colouring-strings

I hope it helps.

All the best,
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  In Console,Python anna17 0 134 Mar-23-2024, 08:24 PM
Last Post: anna17
  Python Flask Realtime system printout (console) ffmpeg jttolleson 3 2,858 Apr-18-2022, 06:39 PM
Last Post: jttolleson
Question convert autohotkey script to python / macro - press key when pixel get colour willson94d 1 3,572 Jan-01-2022, 08:13 PM
Last Post: Yoriz
  Python library for win32 console commands eldiener 3 3,384 Aug-24-2021, 10:28 PM
Last Post: bowlofred
  Problem: Restart kernel onPydev console when trying to install a python package poppy2020 1 7,560 Nov-25-2020, 06:13 PM
Last Post: Larz60+
  to call via console a python-programm Liki 9 3,136 Nov-22-2020, 01:10 AM
Last Post: bowlofred
  My Python Console doesn´t work ModuleNotFoundError: No module named 'tokenize' RuanKishibe 1 3,072 Aug-06-2020, 10:07 PM
Last Post: deanhystad
  how to get some values from js on python console by python code vivekagrey 1 1,835 Feb-13-2020, 09:26 PM
Last Post: micseydel
  I don't know what's wrong with this code [Python Console] H0M1C1D4L_P1G 6 3,130 Dec-22-2019, 10:27 PM
Last Post: snippsat
  Adding markers to Folium map only adding last element. tantony 0 2,094 Oct-16-2019, 03:28 PM
Last Post: tantony

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020