Skip to Main Content
Learning Perl/Tk
book

Learning Perl/Tk

by Nancy Walsh
January 1999
Beginner content levelBeginner
373 pages
9h 43m
English
O'Reilly Media, Inc.
Content preview from Learning Perl/Tk

8.4. Text Indexes

When we talked about listbox index values, each index referred to a line in the listbox. The first line in the listbox was at index 0, and so on. With a text widget, the index can point to a specific line, but it can also point to a character within that line. An index for a text widget is built by using a base index and then optionally modifying that index with a modifier. The entire index, base, and modifier should be put in double quotes.

8.4.1. Base Index Values

"n.m"

This format allows you to explicitly specify a line number and a character number within that line. Lines start at 1 (which is different than the listbox widget), and characters start at 0.

"@x,y"

The character in the widget that is closest to the x,y coordinate.

"end"

The very end of the text widget, after any "\n" characters as well.

"mark"

Specifies the character after the location named mark. The two mark names provided by Tk are "current" and "insert". What they refer to is discussed later in this chapter.

"tag.first"

A tag name is simply a placeholder for some special formatting instructions (discussed in the very next section). After creating tags, you can use this index form. tag.first is the first character in the text widget that is of type tag. That is, you could create a "heading" tag and use "heading.first" index.

"tag.last"

Specifies the character directly after the text marked with tag.

$widget

If you have an embedded widget, you can refer to its location within the text widget ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Perl/Tk

Mastering Perl/Tk

Stephen Lidie, Nancy Walsh

Publisher Resources

ISBN: 1565923146Supplemental ContentCatalog PageErrata