Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making coloured Ascii text with Python

I'm trying to make a title with coloured ascii for my code, which pops up when launching the code. I already know how to make ascii text but not coloured.

This is what I've been able to make, but now I want to have it in magenta.

result = pyfiglet.figlet_format("By Gxzs", font = "slant" )
print(result)

Ascii

I've already tried making it myself using colorama and termcolor, but I get a weird output :

title = pyfiglet.figlet_format(colored("By  Gxzs", color = "magenta"))
print(title)

Output


1 Answers

A high-level library for "rich" text in the terminal is, well, rich. The colorama library that you mentioned is one of its dependencies.

To display the title in magenta, you would do this:

import pyfiglet
from rich import print

title = pyfiglet.figlet_format('By Gxzs', font='slant')
print(f'[magenta]{title}[/magenta]')
like image 120
john-hen Avatar answered Sep 07 '25 20:09

john-hen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!