O'Reilly logo

Tkinter GUI Programming by Example by David Love

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

Line beginning and end

The linestart and lineend strings will refer to the start and end of an index, respectively. These are most useful when you do not explicitly know the index you are working with.

For example, if you wish to add a feature that highlights the entire line at which the cursor is residing, you could get the necessary indexes with the following:

start = str(text.index(tk.INSERT)) + " linestart"end = str(text.index(tk.INSERT)) + " lineend"text.tag_add("sel", start, end)

This again removes the need for splitting off the line number and adding a .0 and .end to it.

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