NumberInput¶
Usage¶
import toga
widget = toga.NumberInput(min=1, max=10, step=0.001)
widget.value = 2.718
NumberInput's properties can accept [Decimal][decimal], [int][], [float][], or [str][] containing numbers, but they always return [Decimal][decimal] objects to ensure precision is retained.
Reference¶
Bases: Widget
Source code in core/src/toga/widgets/numberinput.py
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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
max
property
writable
¶
min
property
writable
¶
on_change
property
writable
¶
The handler to invoke when the value of the widget changes.
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.
step
property
writable
¶
The amount that any increment/decrement operations will apply to the widget's current value. (Not all backends provide increment and decrement buttons.)
value
property
writable
¶
Current value of the widget, rounded to the same number of decimal
places as step, or None if no value has been set.
If this property is set to a value outside of the min/max range, it will be clipped.
While the widget is being edited by the user, it is possible for the UI to contain a value which is outside of the min/max range, or has too many decimal places. In this case, this property will return a value that has been clipped and rounded, and the visible text will be updated to match as soon as the widget loses focus.
__init__(id=None, style=None, step=1, min=None, max=None, value=None, readonly=False, on_change=None, **kwargs)
¶
Create a new number 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 step: The amount that any increment/decrement operations will apply to
the widget's current value.
:param min: If provided, value will be guaranteed to
be greater than or equal to this minimum.
:param max: If provided, value will be guaranteed to
be less than or equal to this maximum.
:param value: The initial value for the widget.
:param readonly: Can the value of the widget be modified by the user?
: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/numberinput.py
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 119 120 121 122 123 124 125 126 | |
Bases: Protocol
Source code in core/src/toga/widgets/numberinput.py
71 72 73 74 75 76 77 | |
__call__(widget, **kwargs)
¶
A handler to invoke when the value is changed.
:param widget: The NumberInput that was changed. :param kwargs: Ensures compatibility with arguments added in future versions.
Source code in core/src/toga/widgets/numberinput.py
72 73 74 75 76 77 | |