Working with tags in Tkinter text widget using python -


i'm trying color text in tkinter text widget of tags in way:

text = self.text_field.get(1.0, 'end') #text_field text widget s = re.findall("\d+", text) in s:     self.text_field.tag_add(i, '1.0', 'end')     self.text_field.tag_configure(i, background='yellow',                                    font='helvetica 14 bold', relief='raised') 

the idea tags being dynamically created, because numbers text widget , can have length. code colors text in widget, need numbers colored.

any suggestions?

when do

tag_add(i, '1.0', 'end') 

you're making tag covers whole text field. need add text on numbers, using .start() , .stop() methods of regex match.

there's example doing syntax highlighting here:
http://forums.devshed.com/python-programming-11/syntax-highlighting-172406.html


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -