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.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 display

  • name: UI element name which can be used internally and for debugging.

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.