Skip to content
Toga
0.5.3.dev143+gabcc6cdb6

MultilineTextInput

A scrollable panel that allows for the display and editing of multiple lines of text.

/reference/images/multilinetextinput-cocoa.png

/reference/images/multilinetextinput-gtk.png

/reference/images/multilinetextinput-winforms.png

/reference/images/multilinetextinput-android.png

/reference/images/multilinetextinput-iOS.png

Not supported

Not supported

Usage

import toga

textbox = toga.MultilineTextInput()
textbox.value = "Some text.\nIt can be multiple lines of text."

The input can be provided a placeholder value - this is a value that will be displayed to the user as a prompt for appropriate content for the widget. This placeholder will only be displayed if the widget has no content; as soon as a value is provided (either by the user, or programmatically), the placeholder content will be hidden.

Notes

  • Winforms does not support the use of partially or fully transparent colors for the MultilineTextInput background. If a color with an alpha value is provided (including TRANSPARENT), the alpha channel will be ignored. A TRANSPARENT background will be rendered as white.

Reference

toga.MultilineTextInput

MultilineTextInput(
    id=None,
    style=None,
    value=None,
    readonly=False,
    placeholder=None,
    on_change=None,
    **kwargs,
)

Bases: Widget

Create a new multi-line text input widget.

PARAMETER DESCRIPTION
id

The ID for the widget.

TYPE: str | None DEFAULT: None

style

A style object. If no style is provided, a default style will be applied to the widget.

TYPE: StyleT | None DEFAULT: None

value

The initial content to display in the widget.

TYPE: str | None DEFAULT: None

readonly

Can the value of the widget be modified by the user?

TYPE: bool DEFAULT: False

placeholder

The content to display as a placeholder when there is no user content to display.

TYPE: str | None DEFAULT: None

on_change

A handler that will be invoked when the value of the widget changes.

TYPE: OnChangeHandler | None DEFAULT: None

kwargs

Initial style properties.

DEFAULT: {}

on_change property writable

on_change

The handler to invoke when the value of the widget changes.

placeholder property writable

placeholder

The placeholder text for the widget.

A value of None will be interpreted and returned as an empty string. Any other object will be converted to a string using str().

readonly property writable

readonly

Can the value of the widget be modified by the user?

This only controls manual changes by the user (i.e., typing at the keyboard). Programmatic changes are permitted while the widget has readonly enabled.

value property writable

value

The text to display in the widget.

A value of None will be interpreted and returned as an empty string. Any other object will be converted to a string using str().

scroll_to_bottom

scroll_to_bottom()

Scroll the view to make the bottom of the text field visible.

scroll_to_top

scroll_to_top()

Scroll the view to make the top of the text field visible.

toga.widgets.multilinetextinput.OnChangeHandler

Bases: Protocol

__call__

__call__(widget, **kwargs)

A handler to invoke when the value is changed.

PARAMETER DESCRIPTION
widget

The MultilineTextInput that was changed.

TYPE: MultilineTextInput

kwargs

Ensures compatibility with arguments added in future versions.

TYPE: Any DEFAULT: {}