O'Reilly logo

Tkinter GUI Application Development Blueprints - Second Edition by Bhaskar Chaudhary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Tags

Tags are used to annotate text with an identification string that can then be used to manipulate the tagged text. Tkinter has a built-in tag called SEL, which is automatically applied to the selected text. In addition to SEL, you can define your own tags. A text range can be associated with multiple tags, and the same tag can be used for many different text ranges.

Here are some examples of tagging:

my_text.tag_add('sel', '1.0', 'end') # add SEL tag from start(1.0) to endmy_text.tag_add('danger', "insert linestart", "insert lineend+1c")my_text.tag_remove('danger', 1.0, "end")my_text.tag_config('danger', background=red)my_text.tag_config('outdated', overstrike=1)

You can specify the visual style for a given tag with tag_config, using ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required