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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset