libstp.ui.screens.basic¶
Basic pre-built screens for common UI patterns.
Classes¶
Shows a message and waits for physical button press. |
|
Two-button confirmation dialog. Returns True or False. |
|
Shows a message with a single dismiss button. |
|
Multiple choice selection. Returns the selected option ID. |
|
Progress/loading screen for use with non-blocking display. |
|
Simple status display screen for non-blocking use. |
Module Contents¶
- class libstp.ui.screens.basic.WaitForButtonScreen(message: str = 'Press the button to continue', icon_name: str = 'touch_app', icon_color: str = 'amber')¶
Bases:
libstp.ui.screen.UIScreen[None]Shows a message and waits for physical button press.
Example
await self.show(WaitForButtonScreen(“Place robot at start”))
- title = 'Ready'¶
- message = 'Press the button to continue'¶
- icon_name = 'touch_app'¶
- icon_color = 'amber'¶
- build() libstp.ui.widgets.Widget¶
Build the screen layout.
Called on every render. Return a Widget tree describing what to display.
- async on_press()¶
- class libstp.ui.screens.basic.ConfirmScreen(title: str, message: str, confirm_label: str = 'Confirm', cancel_label: str = 'Cancel', confirm_style: str = 'success', icon_name: str = 'help_outline', icon_color: str = 'blue')¶
Bases:
libstp.ui.screen.UIScreen[bool]Two-button confirmation dialog. Returns True or False.
Example
- confirmed = await self.show(ConfirmScreen(
“Warning”, “Robot will move. Continue?”
))
- title¶
- message¶
- confirm_label = 'Confirm'¶
- cancel_label = 'Cancel'¶
- confirm_style = 'success'¶
- icon_name = 'help_outline'¶
- icon_color = 'blue'¶
- build() libstp.ui.widgets.Widget¶
Build the screen layout.
Called on every render. Return a Widget tree describing what to display.
- async on_confirm()¶
- async on_cancel()¶
- class libstp.ui.screens.basic.MessageScreen(title: str, message: str, button_label: str = 'OK', icon_name: str | None = None, icon_color: str = 'blue')¶
Bases:
libstp.ui.screen.UIScreen[None]Shows a message with a single dismiss button.
Example
- await self.show(MessageScreen(
“Success”, “Calibration complete!”, icon=”check”, icon_color=”green”
))
- title¶
- message¶
- button_label = 'OK'¶
- icon_name = None¶
- icon_color = 'blue'¶
- build() libstp.ui.widgets.Widget¶
Build the screen layout.
Called on every render. Return a Widget tree describing what to display.
- async on_ok()¶
- class libstp.ui.screens.basic.ChoiceScreen(title: str, message: str, choices: List[tuple], cancel_label: str | None = 'Cancel')¶
Bases:
libstp.ui.screen.UIScreen[str]Multiple choice selection. Returns the selected option ID.
Example
- choice = await self.show(ChoiceScreen(
“Select Mode”, “Choose a driving mode:”, [
(“careful”, “Careful”, “Slow and precise”), (“normal”, “Normal”, “Balanced speed”), (“fast”, “Fast”, “Maximum speed”),
]
))
- title¶
- message¶
- choices¶
- cancel_label = 'Cancel'¶
- build() libstp.ui.widgets.Widget¶
Build the screen layout.
Called on every render. Return a Widget tree describing what to display.
- async on_cancel()¶
- class libstp.ui.screens.basic.ProgressScreen(message: str = 'Please wait...', show_spinner: bool = True, show_progress: bool = False)¶
Bases:
libstp.ui.screen.UIScreen[None]Progress/loading screen for use with non-blocking display.
Use with display() or showing() while running background tasks.
Example
- async with self.showing(ProgressScreen(“Calibrating…”)) as ctx:
- for i in range(100):
ctx.screen.progress = i ctx.screen.status = f”Step {i+1}/100” await ctx.screen.refresh() await asyncio.sleep(0.1)
- title = 'Working'¶
- message = 'Please wait...'¶
- show_spinner = True¶
- show_progress = False¶
- build() libstp.ui.widgets.Widget¶
Build the screen layout.
Called on every render. Return a Widget tree describing what to display.
- class libstp.ui.screens.basic.StatusScreen(message: str, icon_name: str = 'info', icon_color: str = 'blue', status: str = '')¶
Bases:
libstp.ui.screen.UIScreen[None]Simple status display screen for non-blocking use.
Shows an icon, message, and optional status text. Good for showing current state during long operations.
Example
- await self.display(StatusScreen(
“Connecting…”, icon=”wifi”, icon_color=”blue”
))
- title = 'Status'¶
- message¶
- icon_name = 'info'¶
- icon_color = 'blue'¶
- status = ''¶
- build() libstp.ui.widgets.Widget¶
Build the screen layout.
Called on every render. Return a Widget tree describing what to display.