libstp.ui.events ================ .. py:module:: libstp.ui.events .. autoapi-nested-parse:: UI Events - Decorators for binding methods to UI events. Attributes ---------- .. autoapisummary:: libstp.ui.events.F Functions --------- .. autoapisummary:: libstp.ui.events.on_click libstp.ui.events.on_change libstp.ui.events.on_submit libstp.ui.events.on_keypad libstp.ui.events.on_button_press libstp.ui.events.on_slider libstp.ui.events.on_screen_tap Module Contents --------------- .. py:data:: F .. py:function:: on_click(button_id: str) -> Callable[[F], F] Decorator: Called when a button with the given ID is clicked. .. rubric:: Example @on_click("confirm") async def handle_confirm(self): self.close(True) .. py:function:: on_change(widget_id: str) -> Callable[[F], F] Decorator: Called when an input widget's value changes. The handler receives the new value as an argument. .. rubric:: Example @on_change("speed") async def handle_speed_change(self, value: float): self.speed = value await self.refresh() .. py:function:: on_submit(widget_id: Optional[str] = None) -> Callable[[F], F] Decorator: Called when a form/input is submitted. .. rubric:: Example @on_submit() async def handle_submit(self): self.close(self.value) .. py:function:: on_keypad(key: Optional[str] = None) -> Callable[[F], F] Decorator: Called on numeric keypad input. If key is None, handles any key. Handler receives key as argument. Keys: "0"-"9", ".", "back" .. rubric:: Example @on_keypad() async def handle_key(self, key: str): if key == "back": self.input_str = self.input_str[:-1] else: self.input_str += key .. py:function:: on_button_press() -> Callable[[F], F] Decorator: Called when the physical robot button is pressed. .. rubric:: Example @on_button_press() async def handle_button(self): self.close() .. py:function:: on_slider(slider_id: str) -> Callable[[F], F] Decorator: Called when a slider value changes. Handler receives the new value as argument. .. rubric:: Example @on_slider("motor_power") async def handle_power(self, value: float): self.power = value .. py:function:: on_screen_tap() -> Callable[[F], F] Decorator: Called when the screen is tapped anywhere. .. rubric:: Example @on_screen_tap() async def handle_tap(self): self.close()