Tkinter dynamically changing text colour of recurring strings in a textbox
You need to config a tag, and specify that tag when adding the text to the end.This should work (although not tested):
self.txtLog.tag_config("success", foreground="blue", font="Arial 10 italic")log = open(logFile, 'r')while 1: line = log.readline() if len(line) == 0: break else: tags = ("success",) if line.startswith("SUCCESS") else None self.txtLog.insert(Tkinter.END, line+os.linesep, tags)log.close()
Also, I just noticed that you are using tag_add
before tag_config
, I believe it should be the opposite for it to work.