diff --git a/python_payload/st3m/ui/menu.py b/python_payload/st3m/ui/menu.py index efcc8c59207115210d1e6b826dad8839b2d8f63d..bce1738172d52bd02e18181520e9dc62bd1a0c30 100644 --- a/python_payload/st3m/ui/menu.py +++ b/python_payload/st3m/ui/menu.py @@ -87,6 +87,21 @@ class MenuItemAction(MenuItem): def label(self) -> str: return self._label +class MenuItemActionUpdate(MenuItemAction): + """ + A MenuItem which runs the provided lambda action and updates its label with the return value. + """ + + def __init__(self, label: str, action: Callable[[], None]) -> None: + self._label = label + self._action = action + + def press(self, vm: Optional[ViewManager]) -> None: + self._label = self._action() + + def label(self) -> str: + return self._label + class MenuItemLaunchPersistentView(MenuItem): """