rsalmei / alive-progress

A new kind of Progress Bar, with real-time throughput, ETA, and very cool animations!
MIT License
5.53k stars 206 forks source link

ANSI color escape codes not working/supported #229

Closed Lvicek07 closed 1 year ago

Lvicek07 commented 1 year ago

When I try to implement ANSI colour, it just shows the code, doesn't change colour.

title = '\033[93m', "Synchronizing", '\033[91m'
...
bar = alive_it(packet_list, title=title, dual_line=True)

Output: ('\x1b[93m', 'Synchronizing', '\x1b[91m') |████████████████████████████████████████| 11/11 [100%] in 5.5s (2.00/s)

TheTechRobo commented 1 year ago

By using the comma syntax when you're making a variable, you're making a tuple. That's what's getting printed out. A tuple is like a list/array, but it's faster and can't be modified.

Try title = '\033[93m' + "Synchronizing" + '\033[91m' or even title = '\033[93mSynchronizing\033[91m'

rsalmei commented 1 year ago

Hey, thanks @TheTechRobo.

Yep, that's exactly it @Lvicek07, I'm not sure why would you create a tuple for passing such values, but when you pass the correct ones, embedded on the title string, it does work:

https://user-images.githubusercontent.com/6652853/225183291-b6f03947-1317-421a-9022-ece9b4500605.mov

And it actually is a good idea! I liked the effect 👍