Skip to content
Leas Porscha edited this page Aug 30, 2026 · 3 revisions

Page

displaypad_lib.Page — a named 12-key layout with optional auto-timeout.

Creating a Page

from displaypad_lib import Page, LabelKey

page = Page(name="Media")
page[0] = LabelKey("Play", bg_color="green")

Constructor

Page(name="Main", timeout_mode="off", timeout_seconds=10, timeout_target="prev")
Argument Type Default Description
name str "Main" Page name, also usable as a page ID
timeout_mode str "off" See timeout modes below
timeout_seconds int 10 Seconds before timeout fires
timeout_target str|int "prev" Page ID to switch to, or "prev" for the previous page

Timeout Modes

timeout_mode Switches when
"off" Never (stays until manually switched)
"after" timeout_seconds after arriving on this page
"idle" timeout_seconds after the last key press

Registering Pages

pad = DisplayPad()

main = Page(name="Main")
media = Page(name="Media", timeout_mode="idle", timeout_seconds=10, timeout_target="Main")

pad.add_page("Media", media)   # "Main" is registered automatically

Switching Pages

pad.switch_to_page("Media")     # switch and repaint
pad.page_manager.back()         # return to the previous page

Example: Page with a Back Button

from displaypad_lib import DisplayPad, Page, LabelKey

pad = DisplayPad()

main = Page(name="Main")
settings = Page(name="Settings")

class OpenSettings(LabelKey):
    def __init__(self):
        super().__init__("Settings", bg_color="purple")
    def on_press(self):
        pad.switch_to_page("Settings")

class Back(LabelKey):
    def __init__(self):
        super().__init__("Back", bg_color="gray")
    def on_press(self):
        pad.page_manager.back()

main[0] = OpenSettings()
settings[11] = Back()

pad.add_page("Settings", settings)

try:
    while True:
        pad.update(20)
except KeyboardInterrupt:
    pass
finally:
    pad.disable()

See examples/page_example.py for a complete runnable example.

Acknowledgments

Multi-page layout engine and auto-timeout design inspired by ramisotti13-eng/BaseCamp-Linux.

Clone this wiki locally