MultilineTextInput¶
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. ATRANSPARENTbackground will be rendered as white.
Reference¶
Bases: Widget
Source code in core/src/toga/widgets/multilinetextinput.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
on_change
property
writable
¶
The handler to invoke when the value of the widget changes.
placeholder
property
writable
¶
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
¶
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
¶
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().
__init__(id=None, style=None, value=None, readonly=False, placeholder=None, on_change=None, **kwargs)
¶
Create a new multi-line text input widget.
:param id: The ID for the widget. :param style: A style object. If no style is provided, a default style will be applied to the widget. :param value: The initial content to display in the widget. :param readonly: Can the value of the widget be modified by the user? :param placeholder: The content to display as a placeholder when there is no user content to display. :param on_change: A handler that will be invoked when the value of the widget changes. :param kwargs: Initial style properties.
Source code in core/src/toga/widgets/multilinetextinput.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
scroll_to_bottom()
¶
Scroll the view to make the bottom of the text field visible.
Source code in core/src/toga/widgets/multilinetextinput.py
101 102 103 | |
scroll_to_top()
¶
Scroll the view to make the top of the text field visible.
Source code in core/src/toga/widgets/multilinetextinput.py
105 106 107 | |
Bases: Protocol
Source code in core/src/toga/widgets/multilinetextinput.py
11 12 13 14 15 16 17 | |
__call__(widget, **kwargs)
¶
A handler to invoke when the value is changed.
:param widget: The MultilineTextInput that was changed. :param kwargs: Ensures compatibility with arguments added in future versions.
Source code in core/src/toga/widgets/multilinetextinput.py
12 13 14 15 16 17 | |