List more than nine items¶
A how-to guide: a menu numbers its entries 1–9, so a longer list runs on to
further frames a reader pages through.
from sextile import MenuItem, Page, PageRequest, PageRouter, Sextile, menu_page
router = PageRouter()
_PLACES = [
"Aberdeen", "Belfast", "Cardiff", "Dover", "Exeter", "Glasgow", "Hull",
"Ipswich", "Leeds", "Manchester", "Norwich", "Oxford", "Perth", "York",
]
@router.page("1", name="places", title="Places", keywords=("PLACES",))
async def places(request: PageRequest) -> Page:
return menu_page(
request,
items=[MenuItem(name, "", request.app.address_for("places")) for name in _PLACES],
)
app = Sextile(name="Gazetteer", pages=[*router])
PLACES 1a 1 Aberdeen 2 Belfast 3 Cardiff 4 Dover 5 Exeter 6 Glasgow 7 Hull 8 Ipswich 9 Leeds 1-9 select, S page down, 0 index
PLACES 1b 1 Manchester 2 Norwich 3 Oxford 4 Perth 5 York 1-5 select, W page up, 0 index
menu_page takes as many entries as you give it and lays out nine to a frame,
carrying the rest onto the next. The footer names S and W to page down and up;
# turns the frame too. Nothing above has to know how many frames there will be.
A menu is a Part the layout paginates; the parts model is in
Layout, and why a page carries its choices per frame is in
Design decisions.