npcole / npyscreen

Automatically exported from code.google.com/p/npyscreen
Other
481 stars 109 forks source link

string using color #72

Open emper0r opened 5 years ago

emper0r commented 5 years ago

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

vtr0n commented 5 years ago

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