[Tkinter-discuss] Text editing and tags...

Vasilis Vlachoudis Vasilis.Vlachoudis at cern.ch
Tue Dec 11 08:45:10 EST 2018

Hi all,

Considering the following code, it creates a Text() and adds the word "Red" with tag "red"
and "Normal" without  afterwords without any tag.
If you click the cursor in between the two letters d|N from (Red"d" and "N"ormal)
and you start typing, the newly inserted text will be black without out any tag associated.
Is there a way to change this behavior like the word processing editor where the
end of a tag is inclusive that if you start typing at the end of the tag it will assume
that is inside the tag-range and not outside?

import tkinter as tk
txt = tk.Text(root)
txt.pack(fill=tk.BOTH, expand=tk.YES)
txt.tag_configure("red", foreground="Red")

Many thanks
in advance

More information about the Tkinter-discuss mailing list