Previous: Bindings |
The index Parameter
A number of widgets require "index" parameters to be passed. These
are used to point at a specific place in a Text widget, or to
particular characters in an Entry widget, or to particular menu items
in a Menu widget.
Entry widgets have options that refer to character positions in the
text being displayed. You can use these Tkinter functions to access
these special points in text widgets:
- Entry widget indexes (index, view index, etc.
- refers to the last position in the text
- refers to the point where the text cursor is
- indicates the beginning point of the selected text
- denotes the last point of the selected text and finally
- At(x, y=None)
- refers to the character at pixel location x, y (with y not used
in the case of a text entry widget, which is one line of text).
The index notation for Text widgets is very rich and is best described
in the Tk man pages.
- Text widget indexes
Some options and methods for menus manipulate specific menu entries.
Anytime a menu index is needed for an option or a parameter, you may
- Menu indexes (menu.invoke(), menu.entryconfig(), etc.)
- an integer which refers to the numeric position of the entry in
the widget, counted from the top, starting with 0;
- the string "active", which refers to the menu position that is
currently under the cursor;
- the string
"last" which refers to the last menu
- An integer preceded by "@", as in "@6" where the integer is
interpreted as a y pixel coordinate in the menu's coordinate system;
- the string
, which indicates no menu entry at all, most
often used with menu.activate() to deactivate all entries, and
- a text string that is pattern matched against the label of the
menu entry, as scanned from the top of the menu to the bottom. Note
that this index type is considered after all the others, which means
that matches for menu items labelled "last", "active" or "none" may
be interpreted as the above literals, instead.