Checkbox UI element¶
from ui import Checkbox contents = [ ["Apples", 'apples'], #"Apples" will not be checked on activation ["Oranges", 'oranges', True], #"Oranges" will be checked on activation ["Bananas", 'bananas']] selected_fruits = Checkbox(checkbox_contents, i, o).activate()
Implements a checkbox which can be used to enable or disable some functions in your application.
contents: list of checkbox entries which was passed either to
Checkboxconstructor or to
- Checkbox entry structure is a list, where:
entry(entry label) is usually a string which will be displayed in the UI, such as “Option 1”. In case of entry_height > 1, can be a list of strings, each of which represents a corresponding display row occupied by the entry.
entry(entry name) is a name returned by the checkbox upon its exit in a dictionary along with its boolean value.
entry(entry state) is the default state of the entry (checked or not checked). If not present, assumed to be`` default_state``.
You can also pass
Entryobjects as entries -
textwill be used as label and
namewill be used as name.
If you want to set contents after the initalisation, please, use set_contents() method.
pointer: currently selected menu element’s number in
in_foreground: a flag which indicates if checkbox is currently displayed. If it’s not active, inhibits any of menu’s actions which can interfere with other menu or UI element being displayed.
contents: a list of element descriptions, which can be constructed as described in the Checkbox object’s docstring.
o: input&output device objects
name: Checkbox name which can be used internally and for debugging.
entry_height: number of display rows that one checkbox element occupies.
default_state: default state for each entry that doesn’t have a state (entry) specified in
final_button_name: label for the last button that confirms the selection (default:
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_loopmethod while the UI element is active.
self.in_foregroundis True, while callbacks are executed from the input device thread.
Deactivates the UI element, exiting it.
A debug method. Useful for hooking up to an input event so that you can see the representation of current UI element’s contents.
A debug method. Useful for hooking up to an input event so that you can see which UI element is currently active.
Sets the UI element contents and triggers pointer recalculation in the view.