Numeric input UI elements¶
from ui import IntegerAdjustInput
start_from = 0
number = IntegerAdjustInput(start_from, i, o).activate()
if number is None: #Input cancelled
return
#process the number
-
class
ui.
IntegerAdjustInput
(number, i, o, message='Pick a number:', interval=1, name='IntegerAdjustInput', mode='normal', max=None, min=None)[source]¶ Implements a simple number input dialog which allows you to increment/decrement a number using which can be used to navigate through your application, output a list of values or select actions to perform. Is one of the most used elements, used both in system core and in most of the applications.
Attributes:
number
: The number being changed.initial_number
: The number sent to the constructor. Used by reset() method.selected_number
: A flag variable to be returned by activate().in_foreground
: a flag which indicates if UI element is currently displayed. If it’s not active, inhibits any of element’s actions which can interfere with other UI element being displayed.
-
__init__
(number, i, o, message='Pick a number:', interval=1, name='IntegerAdjustInput', mode='normal', max=None, min=None)[source]¶ Initialises the IntegerAdjustInput object.
Args:
number
: number to be operated oni
,o
: input&output device objects
Kwargs:
message
: Message to be shown on the first line of the screen while UI element is active.interval
: Value by which the number is incremented and decremented.name
: UI element name which can be used internally and for debugging.mode
: Number display mode, either “normal” (default) or “hex” (“float” will be supported eventually)min
: minimum value, will not go lower than that.max
: maximum value, will not go higher than that.
-
print_number
()[source]¶ A debug method. Useful for hooking up to an input event so that you can see current number value.
-
activate
()¶ A method which is called when the UI element needs to start operating. Is blocking, sets up input&output devices, refreshes the UI element, then calls the
idle_loop
method while the UI element is active.self.in_foreground
is True, while callbacks are executed from the input device thread.
-
deactivate
()¶ Deactivates the UI element, exiting it.
-
print_name
()¶ A debug method. Useful for hooking up to an input event so that you can see which UI element is currently active.