Number Input#
The Number input is a text input box that is limited to numeric input.

Usage#
import toga
textbox = toga.NumberInput(min_value=1, max_value=10)
Reference#
- class toga.widgets.numberinput.NumberInput(id=None, style=None, factory=None, step=1, min_value=None, max_value=None, value=None, readonly=False, on_change=None, default=None)#
A NumberInput widget specifies a fixed range of possible numbers. The user has two buttons to increment/decrement the value by a step size. Step, min and max can be integers, floats, or Decimals; They can also be specified as strings, which will be converted to Decimals internally. The value of the widget will be evaluated as a Decimal.
- Parameters:
id (str) – An identifier for this widget.
style (
Style
) – an optional style object. If no style is provided then a new one will be created for the widget.step (number) – Step size of the adjustment buttons.
min_value (number) – The minimum bound for the widget’s value.
max_value (number) – The maximum bound for the widget’s value.
value (number) – Initial value for the widget
readonly (bool) – Whether a user can write/change the number input, defaults to False.
on_change (
callable
) – The handler to invoke when the value changes.**ex –
Create a base Toga widget.
This is an abstract base class; it cannot be instantiated.
- Parameters:
id – The ID for the widget.
style – A style object. If no style is provided, a default style will be applied to the widget.
- property max_value#
The maximum bound for the widget’s value.
- Returns:
The maximum bound for the widget’s value. If the maximum bound is None, there is no maximum bound.
- property min_value#
The minimum bound for the widget’s value.
- Returns:
The minimum bound for the widget’s value. If the minimum bound is None, there is no minimum bound.
- property on_change#
The handler to invoke when the value changes.
- Returns:
The function
callable
that is called on a content change.
- property readonly#
Whether a user can write/change the number input.
- Returns:
True
if only read is possible.False
if read and write is possible.
- property step#
The step value for the widget.
- Returns:
The current step value for the widget.
- property value#
Current value contained by the widget.
- Returns:
The current value(int) of the widget. Returns None if the field has no value set.