python - How to highlight a specific word in tkinter? -
i need highlight specific word in text within tkinter frame. in order find word, put balise in html. in text "hello i'm in |house|" want highlight word "house". my frame defined that: class framecodage(frame): self.t2codage = text(self, height=20, width=50) and insert text code: fenetre.fcodage.t2codage.insert(end, res) , res being variable containing text. i saw code on other post: class customtext(tk.text): '''a text widget new method, highlight_pattern() example: text = customtext() text.tag_configure("red", foreground="#ff0000") text.highlight_pattern("this should red", "red") highlight_pattern method simplified python version of tcl code @ http://wiki.tcl.tk/3246 ''' def __init__(self, *args, **kwargs): tk.text.__init__(self, *args, **kwargs) def highlight_pattern(self, pattern, tag, start="1.0", end="end", regexp=false): ...