Text

A multi-line text editor / display.

Example

const t = app.Text({ wrap: 'word', undo: true });
t.pack.configure({ fill: 'both', expand: true });

t.setText('Hello\nworld');
t.insert('end', '\nmore');
console.log(t.getText());

Options

Option Type Description
wrap string 'word', 'char', or 'none'.
undo boolean Enable the built-in undo stack.
font string Text font.
width / height number Size in characters / lines.
state string 'normal' or 'disabled' (read-only).

Methods

Method Description
setText(s) / getText() Replace / read all the text.
insert(index, text) Insert at a text index.
delete(first, last?) Delete a range.
clear() Remove all text.
see(index) / index(idx) Scroll to / resolve an index.

Text indices are 'line.char' (1-based line, 0-based char), or keywords such as 'end' and 'insert' — e.g. '1.0' (start) or 'end-1c' (just before the trailing newline). Plus the inherited widget methods — see Widget basics.

See also