class to convert text with ansi color codes to text with tkinter color tags for now we ignore all but the simplest color directives see http://www.termsys.demon.co.uk/vtansi.htm for a list of other directives it has not been thoroughly tested, but it works well enough for demonstration purposes
Definition at line 6 of file AnsiColorText.py.
Public Member Functions | |
def | __init__ (self, args, kwargs) |
def | register_tag (self, txt, foreground, background) |
def | reset_to_default_attribs (self) |
def | write (self, text, is_editable=False) |
Public Attributes | |
backgroundcolor | |
bright | |
foregroundcolor | |
known_tags | |
tag | |
Static Public Attributes | |
dictionary | background_colors |
color_pat = re.compile('\x01?\x1b\[([\d+;]*?)m\x02?') | |
dictionary | foreground_colors |
inner_color_pat = re.compile("^(\d+;?)+$") | |
def pygui.AnsiColorText.AnsiColorText.__init__ | ( | self, | |
args, | |||
kwargs | |||
) |
initialize our specialized tkinter Text widget
Definition at line 68 of file AnsiColorText.py.
def pygui.AnsiColorText.AnsiColorText.register_tag | ( | self, | |
txt, | |||
foreground, | |||
background | |||
) |
register a tag with name txt and with given foreground and background color
Definition at line 84 of file AnsiColorText.py.
References pygui.AnsiColorText.AnsiColorText.known_tags.
Referenced by pygui.AnsiColorText.AnsiColorText.write().
def pygui.AnsiColorText.AnsiColorText.reset_to_default_attribs | ( | self | ) |
Definition at line 78 of file AnsiColorText.py.
Referenced by pygui.AnsiColorText.AnsiColorText.write().
def pygui.AnsiColorText.AnsiColorText.write | ( | self, | |
text, | |||
is_editable = False |
|||
) |
add text to the text widget
Definition at line 92 of file AnsiColorText.py.
References pygui.AnsiColorText.AnsiColorText.backgroundcolor, pygui.AnsiColorText.AnsiColorText.bright, pygui.AnsiColorText.AnsiColorText.foregroundcolor, pygui.AnsiColorText.AnsiColorText.known_tags, pygui.AnsiColorText.AnsiColorText.register_tag(), pygui.AnsiColorText.AnsiColorText.reset_to_default_attribs(), and pygui.AnsiColorText.AnsiColorText.tag.
|
static |
Definition at line 40 of file AnsiColorText.py.
pygui.AnsiColorText.AnsiColorText.backgroundcolor |
Definition at line 82 of file AnsiColorText.py.
Referenced by pygui.AnsiColorText.AnsiColorText.write().
pygui.AnsiColorText.AnsiColorText.bright |
Definition at line 80 of file AnsiColorText.py.
Referenced by pygui.AnsiColorText.AnsiColorText.write().
|
static |
Definition at line 65 of file AnsiColorText.py.
|
static |
Definition at line 17 of file AnsiColorText.py.
pygui.AnsiColorText.AnsiColorText.foregroundcolor |
Definition at line 81 of file AnsiColorText.py.
Referenced by pygui.AnsiColorText.AnsiColorText.write().
|
static |
Definition at line 66 of file AnsiColorText.py.
pygui.AnsiColorText.AnsiColorText.known_tags |
Definition at line 73 of file AnsiColorText.py.
Referenced by pygui.AnsiColorText.AnsiColorText.register_tag(), and pygui.AnsiColorText.AnsiColorText.write().
pygui.AnsiColorText.AnsiColorText.tag |
Definition at line 79 of file AnsiColorText.py.
Referenced by pygui.AnsiColorText.AnsiColorText.write().