Module userland.scripts.nua

New user application script

Functions

async def main(cx: SSHContext) ‑> str

Classes

class NuaApp (context: SSHContext, **kwargs)

New user application

Create an instance of an app.

Args

driver_class
Driver class or None to auto-detect. This will be used by some Textual tools.
css_path
Path to CSS or None to use the CSS_PATH class 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 run with the dev switch.

Raises

CssPathError
When the supplied CSS path(s) are an unexpected type.
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")

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]

Yield child widgets for a container.

This method should be implemented in a subclass.

async def on_button_pressed(self, event: textual.widgets._button.Button.Pressed) ‑> None
async def on_key(self, event: textual.events.Key) ‑> None

Inherited members