Character input UI elements¶
from ui import CharArrowKeysInput
password = CharArrowKeysInput(i, o, message="Password:", name="My password dialog").activate()
if password is None: #UI element exited
return False #Cancelling
#processing the input you received...
-
class
ui.char_input.
CharArrowKeysInput
(i, o, message='Value:', value='', allowed_chars=['][S', '][c', '][C', '][s', '][n'], name='CharArrowKeysInput', initial_value='')[source]¶ Implements a character input dialog which allows to input a character string using arrow keys to scroll through characters
-
__init__
(i, o, message='Value:', value='', allowed_chars=['][S', '][c', '][C', '][s', '][n'], name='CharArrowKeysInput', initial_value='')[source]¶ Initialises the CharArrowKeysInput object.
Args:
i
,o
: input&output device objects
Kwargs:
value
: Value to be edited. If not set, will start with an empty string.allowed_chars
: Characters to be used during input. Is a list of strings designating ranges which can be the following:- ‘][c’ for lowercase ASCII characters
- ‘][C’ for uppercase ASCII characters
- ‘][s’ for special characters
- ‘][S’ for space
- ‘][n’ for numbers
- ‘][h’ for hexadecimal characters (0-F)
If a string does not designate a range of characters, it’ll be added to character map as-is.
message
: Message to be shown in the first row of the displayname
: UI element name which can be used internally and for debugging.
-
activate
()[source]¶ A method which is called when input element needs to start operating. Is blocking, sets up input&output devices, renders the element and waits until self.in_background is False, while menu callbacks are executed from the input device thread. This method returns the selected value if KEY_ENTER was pressed, thus accepting the selection. This method returns None when the UI element was exited by KEY_LEFT and thus the value was not accepted.
-
print_value
()[source]¶ A debug method. Useful for hooking up to an input event so that you can see current value.
-
print_name
()[source]¶ A debug method. Useful for hooking up to an input event so that you can see which UI element is currently processing input events.
-
move_up
(*args, **kwargs)[source]¶ Changes the current character to the next character in the charmap
-
move_down
(*args, **kwargs)[source]¶ Changes the current character to the previous character in the charmap
-