modern_urwid.lifecycle.manager
Classes
|
Manages multiple layouts and shared resources between them. |
- class modern_urwid.lifecycle.manager.LifecycleManager(context: CompileContext, loop: MainLoop | None = None)
Bases:
objectManages 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:
ValueError – Raises if an incorrect key value is found
TypeError – Raises if the provided controller does not extend
Controller
- 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’son_exit()method.- Parameters:
name (str) – Layout name to switch to
- Raises:
LayoutNotFound – Raises if a layout is not found with the given name