Reference (PiFace CAD Tools)

class, answers, selector='>', cad=None)

Asks a question on the LCD”

  • question (string) – The question to be asked.
  • answers (list) – The answers to choose from.
  • selector (string) – The selector displayed in front of each answer.
  • cad (PiFaceCAD) – An already initialised PiFaceCAD object.

Asks the question using the LCD screen.

Returns:int – index of the answer selected.

class, custom_values=None, cad=None)

Allows the user to input text using the LCD.

To change mode from moving and editing press switch 5 (navigation switch in). Move the navigation switch side to side (switches 6 and 7) to change character.

The available character set is specified using a format string similar to printf. Supported character specifiers are:

c: Characters
C: Capital Characters
i: Integers
d: Integers
x: Hexadecimal
X: Capital Hexadecimal
.: Punctuation
m: Custom (specifed by ``custom_values`` in init args)
r: Return (switch 5 to submit string)

You must prefix them with a % symbol and you can also specify a number argument. Each specifier is returned as an element in a list.

For example:

>>> scanner ="Text: %c%2i%.%r")
>>> print(scanner.scan())  # user enters things on PiFaceCAD
['a', '13', '!']

You can also specify custom values:

>>> scanner =
...     "Animal: %m%r",
...     custom_values=('cat', 'dog', 'fish')
... )
>>> print(scanner.scan())

move cursor left, roll around string, scroll screen. Only place cursor on ValueSelect, ignore plain text.


move cursor right, roll around string, scroll screen. Only place cursor on ValueSelect, ignore plain text.

class, value_select, custom_values=None)

A list of ValueSelects representing a single value.

class, []value_index=0)

A character in a specified range


Return the length of the longest value in this list. Example:

ValueSelect(["one", "two", "three"]).longest_len() == 5
class, custom_values=None)

A list of ValueSelect’s and characters, representing a string.


Returns the first index of an instance of instance_type


Returns a list of currently selected values.


Returns the ValueSelect or character at the string index. The string index is the index of this ValueSelectString as if it is being treated as a string.


cs0 == CustomValueSelect == ["bb", "cc"]
cs1 == CustomValueSelect == ["dd", "ee"]
vss == ValueSelectString == ["a", cs0, cs1, "f"]
vss == ["a", ["bb", "cc"], ["dd", "ee"], "f"]
str(vss) == "abbddf"
vss.value_at(0) == "a"
vss.value_at(1) == cs0
vss.value_at(2) == cs0
vss.value_at(3) == cs1
vss.value_at(5) == "f"
str(vss.value_at(2)) == "bb", c2)

Generates the characters from c1 to c2, inclusive.

Returns True if given character is a number, False otherwise., col)

Returns True if the character can be selected