pythonware.com products ::: library ::: search ::: daily Python-URL!
   

Concepts

Back   Next   

 Concepts

 Indexes

The Entry widget allows you to specify character positions in a number of ways:

  • Numerical indexes

  • ANCHOR

  • END

  • INSERT

  • Mouse coordinates

Numerical indexes work just like Python list indexes. The characters in the string are numbered from 0 and upwards. You specify ranges just like you slice lists in Python; for example, (0, 5) corresponds to the first five characters in the entry widget.

ANCHOR (or "anchor") corresponds to the start of the selection, if any. You can use the select_from method to change this from the program.

END (or "end") corresponds to the position just after the last character in the entry widget. The range (0, END) corresponds to all characters in the widget.

INSERT (or "insert") corresponds to the current position of the text cursor. You can use the icursor method to change this from the program.

Finally, you can use the mouse position for the index, using the following syntax:

    "@%d" % x

where x is given in pixels relative to the left edge of the entry widget.

Back   Next