Entry Methods

In addition to configure and cget, the following methods are supported for the Entry widget:

delete

Deletes text from the widget. For example, to delete the selected text:

$entry->delete('sel.first', 'sel.last');
get

Gets the contents of the Entry widget. For example:

$input = $entry->get;
icursor

Places the cursor at the specified index. For example, to move the cursor to the end of the entry string:

$entry->icursor('end');
index

Converts a named index into a numeric one:

$length = $entry->index('end');
insert

Inserts text at the specified index. For example, to append the “.txt” string to the end of the entry string:

$entry -> insert('end', '.txt');
selection

Manipulates the selected block. The first argument can be any of:

adjust

Extends selected text to the index specified in the second argument:

$entry->selection('adjust', 'end');
clear

Clears the selection block:

$entry->selection('clear');
from

Resets the anchor index to the index specified in the second argument:

$entry->selection('from',0);
present

Determines if any text is currently selected:

if ($entry->selection('present')) {
        $entry->delete('sel.first','sel.last');
}
range

Changes the selection range to the indexes specified in the second and third arguments. For example, to change the selection to include the entire entry string:

$entry->selection('range',0,'end');
to

Extends the selection from the current anchor position to the specified index:

$entry->selection('to','insert');
xview

Manipulates the text in view. With no arguments, returns ...

Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.