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
IntegerAdjustInput(number, i, o, message='Pick a number:', interval=1, name='IntegerAdjustInput')¶
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.
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')¶
Initialises the IntegerAdjustInput object.
number: number to be operated on
o: input&output device objects
message: Message to be shown on the first line of the screen when 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.
A method which is called when input element needs to start operating. Is blocking, sets up input&output devices, renders the UI element and waits until self.in_background is False, while callbacks are executed from the input device thread. This method returns the selected number if KEY_ENTER was pressed, thus accepting the selection. This method returns None when the UI element was exited by KEY_LEFT and thus it’s assumed changes to the number were not accepted.
Deactivates the UI element, exiting it and thus making activate() return.
A debug method. Useful for hooking up to an input event so that you can see which UI element is currently processing input events.
A debug method. Useful for hooking up to an input event so that you can see current number value.