npyscreen icon indicating copy to clipboard operation
npyscreen copied to clipboard

string using color

Open emper0r opened this issue 5 years ago • 1 comments

Hi,

I read into documentation about color to set Theme, in case I want to change not the Theme BUT, how can I change only some word into msg notify ?

this a WARNING! message.!

this is .... message -> white bold WARNING -> only red this word between the white bolds of "this is.... message"

is possible to do it ?

I try it using colorama library but works using normally with print() function but adding the code into npyscreen notify window, output the message changing the color by bash code to put red so. came this way as result.

This is a [0;31m'Warning message.

And of course all message was white using theme of npyscreen.

I can reach to put color string in the print but show up in the wrong position

this is the code:

def Red(string): print("\033[91m {}\033[00m" .format(string))

in the class to notify on npyscreen ... msg = 'Must to be' + str(self.Red('debian-keyring')) + 'installed' npyscreen.notify_confirm(msg)

and the windows show up this way putting the red word out instead between the message.

schermata 2018-11-06 alle 11 34 23

if I not use the function and putting directly into the msg to not print outside show up without formated color.

schermata 2018-11-06 alle 11 52 06

any idea ? thanks any way

emper0r avatar Nov 06 '18 10:11 emper0r

Hi, look this post: https://medium.com/@ValTron/create-tui-on-python-71377849879d

vtr0n avatar Dec 29 '18 15:12 vtr0n