It prints correctly in violet on the terminal, but does not print in color on the widget
Why does the widget not print color? By incorporating.tag_config(...)
Twidg.insert(...)
is thus added before mainloop()
.
Snippet:
# Configure a tag for colored text
Twidg.tag_config('\033[35mviolet', foreground='purple')
# Redirection of output
sys.stdout.write = redir
# Printing colored text in ScrolledText widget
Twidg.insert(INSERT, "violet\n", '\033[35mviolet') # Insert colored text
fen.mainloop()
Screenshot:
As above, you will see color on widget.