Entry Methods
In addition to configure
and cget, the following methods
are supported for the Entry widget:
deleteDeletes text from the widget. For example, to delete the selected text:
$entry->delete('sel.first', 'sel.last');getGets the contents of the Entry widget. For example:
$input = $entry->get;
icursorPlaces the cursor at the specified index. For example, to move the cursor to the end of the entry string:
$entry->icursor('end');indexConverts a named index into a numeric one:
$length = $entry->index('end');insertInserts text at the specified index. For example, to append the “.txt” string to the end of the entry string:
$entry -> insert('end', '.txt');selectionManipulates the selected block. The first argument can be any of:
adjustExtends selected text to the index specified in the second argument:
$entry->selection('adjust', 'end');clearClears the selection block:
$entry->selection('clear');fromResets the
anchorindex to the index specified in the second argument:$entry->selection('from',0);presentDetermines if any text is currently selected:
if ($entry->selection('present')) { $entry->delete('sel.first','sel.last'); }rangeChanges 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');toExtends the selection from the current anchor position to the specified index:
$entry->selection('to','insert');
xviewManipulates the text in view. With no arguments, returns ...
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.
Read now
Unlock full access