Search code examples
python-3.xcolorama

How to change Python background to a certain colour with colorama?


I am using colorama to change the colour of my text and it works fines, but now I want to change the colour of the whole background instead of just my text.

I am using Windows:

import colorama
from colorama import Fore, Back, Style

colorama.init()

print(Back.GREEN)
print(Fore.RED)

But, that code only makes the text coloured. Is there a way to do that in python? I want it like CMD where you can have the background of it a colour. I cannot use the OS module as I do not have admin rights, but I'm open to using any other module.

How do I solve this problem?


Solution

  • After a while in playing with it i figured it out. Just forgot about this post. Here is what I did.

    import colorama
    from colorama import Back as bg
    
    colorama.init()
    print(bg.RED)
    print(colorama.ansi.clear_screen())
    

    I think clearing the screen fixed the Issue