Skip to main content

Page

Page is the top most container for all other controls. It is is automatically added when a new page is created or app session started.

Page control has a reserved page control ID. You cannot add Page control, however you can change its properties. Technically, the Page is a vertical Stack control, so it has similar behavior and shares some properties.

Properties

NameTypeDefaultDescription
titlestring{page_name} - pgletA title of browser window.
verticalFillboolfalseDefines whether page contents takes 100% of the height of browser window.
horizontalAlignstringstartDefines how to align page children horizontally: start, end, center, space-between, space-around, space-evenly, baseline or stretch.
verticalAlignstringDefines how to align page children vertically: start, end, center, space-between, space-around, space-evenly, baseline or stretch.
widthstring100%The width of a page container.
paddingstring10pxThe padding of a page container.
gapstring10A gap between page child controls.

Examples

Creating a new page with a random name and connecting to it:

import pglet

page = pglet.page()

Create a new app with name app1 and wait for connections. web=True makes app UI displaying at Pglet service. main function is an entry point for a new user session. When a new user connects we just greem them with Hello, world! message:

def main(page):
page.add(Text(value="Hello, world!"))

pglet.app("app1", web=True, target=main)

To update page title:

page.update(Page(title="My App!"))