The text input widget is a simple input field for user entry of text data.
import toga input = toga.TextInput(placeholder='enter name here')
- class toga.widgets.textinput.TextInput(id=None, style=None, factory=None, value=None, placeholder=None, readonly=False, on_change=None, on_gain_focus=None, on_lose_focus=None, validators=None, initial=None)#
A widget get user input.
id (str) – An identifier for this widget.
Style) – An optional style object. If no style is provided then a new one will be created for the widget.
value (str) – The initial text for the input.
placeholder (str) – If no input is present this text is shown.
readonly (bool) – Whether a user can write into the text input, defaults to False.
callable) – Method to be called when text is changed in text box
validators (list) – list of validators to run on the value of the text box. Should return None is value is valid and an error message if not.
on_change – The handler to invoke when the text changes.
callable) – Function to execute when get focused.
callable) – Function to execute when lose focus.
- MIN_WIDTH = 100#
Add the provided widgets as children of this widget.
If a node already has a different parent, it will be moved over. This does nothing if a node already is a child of this node.
ValueErrorif this widget cannot have children.
children – The widgets to add as children of this widget.
- property app#
The App to which this widget belongs.
When setting the app for a widget, all children of this widget will be recursively assigned to the same app.
ValueErrorif the widget is already associated with another app.
- property can_have_children#
Determine if the node can have children.
This does not resolve whether there actually are any children; it only confirms whether children are theoretically allowed.
- property children#
The children of this node. This always returns a list, even if the node is a leaf and cannot have children.
A list of the children for this widget.
Clears the text of the widget.
- property enabled#
Is the widget currently enabled? i.e., can the user interact with the widget?
Set this widget to have the current input focus.
- property id#
The node identifier. This id can be used to target styling directives.
- insert(index, child)#
Insert a widget as a child of this widget.
If the node already has a parent, ownership of the widget will be transferred.
ValueErrorif this node cannot have children.
index – The position in the list of children where the new widget should be added.
child – The child to insert as a child of this node.
- property is_valid#
- property on_change#
The handler to invoke when the value changes.
callablethat is called on a content change.
- property on_gain_focus#
The handler to invoke when the widget get focus.
callablethat is called on widget focus gain.
- property on_lose_focus#
The handler to invoke when the widget lose focus.
callablethat is called on widget focus loss.
- property parent#
The parent of this node.
The parent of this node. Returns None if this node is the root node.
- property placeholder#
The placeholder text.
The placeholder text as a
- property readonly#
Whether a user can write into the text input.
Trueif only read is possible.
Falseif read and write is possible.
Refresh the layout and appearance of the tree this node is contained in.
Remove the provided widgets as children of this node.
This does nothing if a given node is not a child of this node.
ValueErrorif this node is a leaf, and cannot have children.
children – The child nodes to remove.
- property root#
The root of the tree containing this node.
The root node. Returns self if this node is the root node.
- property tab_index#
The position of the widget in the focus chain for the window.
- property validators#
- property value#
The value of the text input field.
The current text of the widget as a
- property window#
The window to which this widget belongs.
When setting the window for a widget, all children of this widget will be recursively assigned to the same window.