Printer UI element

from ui import Printer
Printer(["Line 1", "Line 2"], i, o, 3, skippable=True)
Printer("Long lines will be autosplit", i, o, 1)
ui.Printer(message, i, o, sleep_time=1, skippable=True)[source]

Outputs a string, or a list of strings, on a display as soon as it’s called. A string will be split into a list, a list will not be modified. The resulting list is then displayed string-by-string. If resulting strings will take more than one screen, they’ll be split into multiple screenfuls and shown one-by-one.

Args:

  • message: A string or list of strings to display.
  • i, o: input&output device objects. If you’re not using skippable=True and don’t need exit on KEY_LEFT, feel free to pass None as i.

Kwargs:

  • sleep_time: Time to display each the message (for each of resulting screens).
  • skippable: If set, allows skipping message screens by pressing ENTER.
ui.PrettyPrinter(text, i, o, *args, **kwargs)[source]

Outputs string data on display as soon as it’s called. Will pass the data through format_for_screen function before passing it on to Printer. If text will take more than one screen, it’ll be split into multiple screenfuls to fit.

Args:

  • message: A string to be displayed.
  • i, o: input&output device objects. If you’re not using skippable=True and don’t need exit on KEY_LEFT, feel free to pass None as i.

Kwargs:

  • sleep_time: Time to display each screenful of text.
  • skippable: If set, allows skipping screens by pressing ENTER.
ui.GraphicsPrinter(image_or_path, i, o, sleep_time=1, invert=True)[source]

Outputs image on the display, as soon as it’s called. You can use either a PIL image, or a relative/absolute path to a suitable image. The GraphicsPrinter automatically uses the fit_image_to_screen function to make sure the image can display regardless of image or screen size.

Args:

  • image_or_path: Either a PIL image or path to an image to be displayed.
  • i, o: input&output device objects. If you don’t need/want exit on KEY_LEFT, feel free to pass None as i.

Kwargs:

  • sleep_time: Time to display the image
  • invert: Invert the image before displaying (True by default).