SolarOS

SolarOS 4.13.4 manual · api

Python text user-interface API

API overview · Lua text user interfaces

Use the shared layout on displays and cursor-addressable port shells:

from solaros import tui
_, _, body, _, _, _ = tui.layout()
tui.title("Example")
tui.cell(body[0], 0, body[3], "Shared layout")
tui.help("Enter open  Esc exit")

solaros.tui

TUI functions provide a small curses-like text UI layer over the SolarOS terminal. Drawing calls are queued onto the foreground UI side, so Python scripts do not write terminal memory directly.

Attributes:

Functions:

Common key constants include KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, KEY_CTRL_LEFT, KEY_CTRL_RIGHT, KEY_HOME, KEY_END, KEY_DELETE, KEY_ESCAPE, KEY_PAGE_UP, and KEY_PAGE_DOWN.

Example:

import solaros
from solaros import tui

rows, cols = tui.size()
tui.clear()
tui.box(0, 0, rows, cols)
tui.addstr(1, 2, "SolarOS TUI", tui.BOLD)
tui.addstr(3, 2, "Press ESC")
tui.refresh()

while not solaros.should_exit():
    key = tui.getch(250)
    if key == tui.KEY_ESCAPE:
        break

Quick reference

High-level: layout, cell, title, help, tab, list_move, input_edit, input. Rectangles are (row, col, height, width). The low-level API remains.

input(row, col, width, label, text, cursor, view[, attr[, masked]]) draws an editable input row. Set masked=True to draw one * per UTF-8 character. The mask is render-only: text and the value returned by input_edit() remain unchanged, so a script must still avoid logging secrets and discard them when they are no longer needed.

Use tui.getch() for keyboard characters and navigation keys. Use solaros.input.read() for foreground touch, mouse, and joystick events.

Join us on: