sextile.pages

One-call page shapes: the commonest Viewdata pages, each said in a call.

A notice, a menu, some prose. Each takes the request the page answers and builds a PageLayout, so the title, the way home and the page number default from the request exactly as they do for the layout underneath, and a page that outgrows the one-call form graduates to a full PageLayout without changing shape.

async def now(request: PageRequest) -> Page:

return notice_page(request, “It is noon.”)

The framework’s own notices are these too: Sextile.not_found, .failed and .timed_out build a notice_page with furniture=().

sextile.pages.farewell_page(request, title, *lines, hang_up=True)[source]

The page a caller sees last, after which the line drops.

A notice_page with no furniture and no way home: a footer offering the index would mislead on a page there is no coming back from, and the rows it and the rules would take are the ones worth leaving blank, the reader being about to talk to their modem.

Parameters:
  • request (PageRequest) – The request this page answers.

  • title (str) – The heading, drawn in cyan on the first row.

  • *lines (str) – What to say, one string a row, beginning two rows below the title.

  • hang_up (bool) – Whether the line drops once shown. False for the involuntary parting, where the session drops the line itself.

Return type:

Page

Returns:

A page of a single frame, offering no keys.

sextile.pages.menu_page(request, *, items, title=None, home=<sextile.layout.page.DefaultHome object>, preamble=(), empty=None, shortcuts=(), neighbours=None, item_noun='item')[source]

A menu: a list of choices, nine to a frame, each numbered 1-9.

Parameters:
  • request (PageRequest) – The request this page answers.

  • items (Sequence[Entry]) – The choices, anything satisfying Entry; MenuItem is the ready-made one. A service with a richer type of its own passes it directly.

  • title (str | None) – The header, or None to take the registered title of the page.

  • home (PageAddress | Shortcut | None | DefaultHome) – Where 0 leads; unset takes request.app.index, None offers no way home.

  • preamble (Sequence[str]) – Lines shown once on the first frame, above the entries, with a blank row between.

  • empty (str | Sequence[str] | None) – Said in place of the entries where there are none, so an empty menu explains itself rather than looking like a fault. A string is one row, a sequence its rows as given. None leaves the frame blank.

  • shortcuts (Sequence[Shortcut]) – Keys offered on every frame besides the digits and 0.

  • neighbours (Neighbours | None) – The pages either side of this one, wiring A/D; pass request.neighbours.

  • item_noun (str) – What A and D move between, as the footer names it.

Return type:

Page

Returns:

The page, of as many frames as the entries needed.

sextile.pages.notice_page(request, *lines, title=None, home=<sextile.layout.page.DefaultHome object>, numbered=True, shortcuts=(), hang_up=False, furniture=(Header(colour=<Colour.CYAN: 6>, numbered=<Colour.WHITE: 7>, edge=<Edge.TOP: 1>, rows=1, _ATTRIBUTES=2, _GAP=1), Rule(edge=<Edge.TOP: 1>, colour=<Colour.BLUE: 4>, rows=1), Rule(edge=<Edge.BOTTOM: 2>, colour=<Colour.BLUE: 4>, rows=1), Footer(colour=<Colour.YELLOW: 3>, edge=<Edge.BOTTOM: 2>, rows=1)))[source]

A page that simply says something.

Parameters:
  • request (PageRequest) – The request this page answers.

  • *lines (str) – What to say, one string a row; empty strings leave a blank row.

  • title (str | None) – The header, or None to take the registered title of the page.

  • home (PageAddress | Shortcut | None | DefaultHome) – Where 0 leads; unset takes request.app.index, None offers no way home.

  • numbered (bool) – Whether the header shows the page number. False for a notice answering a request that names no page of its own.

  • shortcuts (Sequence[Shortcut]) – Keys offered on every frame besides the digits and 0.

  • hang_up (bool) – Whether the line drops once the page has been shown.

  • furniture (Sequence[Furnishing]) – The bands round the content. () draws a masthead-style notice with no header or footer, where the title heads the content in cyan instead; this is how the framework says things for itself.

Return type:

Page

Returns:

The page, of as many frames as the lines needed.

sextile.pages.prose_page(request, *paragraphs, title=None, home=<sextile.layout.page.DefaultHome object>, shortcuts=())[source]

A page of running text, the line breaks left to the framework.

Parameters:
  • request (PageRequest) – The request this page answers.

  • *paragraphs (str) – The paragraphs, each wrapped to the frame and spaced from the next. A long one runs on to further frames rather than being cut.

  • title (str | None) – The header, or None to take the registered title of the page.

  • home (PageAddress | Shortcut | None | DefaultHome) – Where 0 leads; unset takes request.app.index, None offers no way home.

  • shortcuts (Sequence[Shortcut]) – Keys offered on every frame besides the digits and 0.

Return type:

Page

Returns:

The page, of as many frames as the text needed.

sextile.pages.title_page(request, *, draw, next_page=None, shortcuts=())[source]

The whole-frame title a service opens on, drawn by the caller.

Parameters:
  • request (PageRequest) – The request this page answers.

  • draw (Callable[[Canvas], None]) – Draws the frame, given the canvas; it has every row, from 0.

  • next_page (PageAddress | None) – Where # leads once the frame has been read, the service’s index by default. # is the one key a viewdata reader tries without being told, and a title frame is an invitation to press it.

  • shortcuts (Sequence[Shortcut]) – Keys offered on the frame besides #.

Returns:

a masthead is the whole frame, and there is no index to send a reader back to that they are not already at.

Return type:

Page