Printer UI element¶
from ui import Printer
Printer(["Line 1", "Line 2"], i, o, 3, exitable=True)
Printer("Long lines will be autosplit", i, o, 1)
-
ui.printer.
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 presing ENTER.
-
ui.printer.
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 presing ENTER.
-
ui.printer.
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
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 imageinvert
: Invert the image before displaying (True by default)