modern_urwid.lifecycle.manager

Classes

LifecycleManager(context[, loop])

Manages multiple layouts and shared resources between them.

class modern_urwid.lifecycle.manager.LifecycleManager(context: CompileContext, loop: MainLoop | None = None)

Bases: object

Manages multiple layouts and shared resources between them.

get_loop() MainLoop

Get this manager’s mainloop

Returns:

The mainloop this manager uses

Return type:

urwid.MainLoop

register(layout_path: str | Path, key: str | None = None)

Register a new layout

Parameters:
  • layout_path (str | pathlib.Path) – Layout name to switch to

  • key (str, optional) – The key to register the layout under

Raises:
run(name: str | None = None)

Run the MainLoop

Parameters:

name (str, optional) – If provided, switch to this layout before running

switch(name: str)

Switch to a different layout by name.

Calls the new controller’s on_enter() method, and the old controller’s on_exit() method.

Parameters:

name (str) – Layout name to switch to

Raises:

LayoutNotFound – Raises if a layout is not found with the given name