How to make blinking text in python with termcolor?

1k Views Asked by At

Whenever I try to use termcolor to make blinking text, using the following code:

from termcolor import colored, cprint
cprint('\nJames Everleigh', 'red', attrs=['blink'])

It prints the text red, but it doesn't blink. Is there some function that I need to use to turn the blinking on/something like that?

I use replit.com which is using python 3.8.2. I've also tried Visual Studio but it still doesn't blink.

3

There are 3 best solutions below

1
0xDEADBEEF On

You can use the curses library to do some cool stuff inside a terminal (only for Linux).

Here is the documentation : https://docs.python.org/3.7/howto/curses.html

0
LittlePanic404 On

Try print("\033[5mHello\033[0m\n") (from https://unix.stackexchange.com/questions/269809/blink-codeescape-code-has-been-removed )

It work for me, I'm using terminator. Should work with other terminal emulator too. And according to this, VScode have an integrated terminal, so you can try with it and tell us how it goes :)

0
Russ1337 On

The terminal you're using may not support the blink attribute. Refer to the documentation under Terminal properties to check if your terminal supports it.