Tkinter's indexing system

Indexing is handled in a somewhat coordinate-based way. An index is represented by two numbers separated by a single full stop. For example: 4.5.

The first number (before the .) in this index can be thought of as the line number. This begins at 1.

The second number (after the .) is how many characters into the line we are. This begins at 0.

The first character within a Text widget will therefore be located at 1.0. This means line 1, 0 characters in.

To ensure we fully understand this concept, let's create a demo application which will show us where the cursor is located at all times.

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

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