79630592

Date: 2025-05-20 14:00:16
Score: 1
Natty:
Report link

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:

enter image description here

As above, you will see color on widget.

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: Adios Gringo