Module userland.scripts.nua
New user application script
Functions
async def main(cx: SSHContext) ‑> str-
Expand source code
async def main(cx: SSHContext) -> str: cx.console.set_window_title("new user application") return await NuaApp(cx).run_async() # type: ignore
Classes
class NuaApp (context: SSHContext,
**kwargs)-
Expand source code
class NuaApp(XthuluApp): """New user application""" CSS = """ Button { margin-bottom: 1; width: 24; } """ """Stylesheet""" def compose(self) -> ComposeResult: yield Center( Middle( Button("Continue as guest", variant="success", name="guest"), Button("Create an account", variant="primary", name="create"), Button("Log off", variant="error", name="logoff"), ), ) async def on_button_pressed(self, event: Button.Pressed) -> None: if event.button.name == "guest": return self.exit(result="guest") if event.button.name == "logoff": return self.exit(result="logoff") self.exit(result="create") async def on_key(self, event: events.Key) -> None: if event.key != "escape": return self.exit(result="logoff")New user application
Create an instance of an app.
Args
driver_class- Driver class or
Noneto auto-detect. This will be used by some Textual tools. css_path- Path to CSS or
Noneto use theCSS_PATHclass variable. To load multiple CSS files, pass a list of strings or paths which will be loaded in order. watch_css- Reload CSS if the files changed. This is set automatically if
you are using
textual runwith thedevswitch. ansi_color- Allow ANSI colors if
True, or convert ANSI colors to to RGB ifFalse.
Raises
CssPathError- When the supplied CSS path(s) are an unexpected type.
Ancestors
- XthuluApp
- textual.app.App
- typing.Generic
- textual.dom.DOMNode
- textual.message_pump.MessagePump
Class variables
var CSS-
Stylesheet
Methods
def compose(self) ‑> Iterable[textual.widget.Widget]-
Expand source code
def compose(self) -> ComposeResult: yield Center( Middle( Button("Continue as guest", variant="success", name="guest"), Button("Create an account", variant="primary", name="create"), Button("Log off", variant="error", name="logoff"), ), )Yield child widgets for a container.
This method should be implemented in a subclass.
-
Expand source code
async def on_button_pressed(self, event: Button.Pressed) -> None: if event.button.name == "guest": return self.exit(result="guest") if event.button.name == "logoff": return self.exit(result="logoff") self.exit(result="create") async def on_key(self, event: textual.events.Key) ‑> None-
Expand source code
async def on_key(self, event: events.Key) -> None: if event.key != "escape": return self.exit(result="logoff")
Inherited members