diff --git a/src/main.py b/src/main.py index 41521b1..af5ce57 100644 --- a/src/main.py +++ b/src/main.py @@ -72,13 +72,8 @@ def on_exit_btn(self) -> None: task.cancel() App.get_running_app().stop() - def update_view(self, view_name: str): - self.view_name = view_name - async def app_func(self): async def run_wrapper(): - # we don't actually need to set asyncio as the lib because it is - # the default, but it doesn't hurt to be explicit await self.async_run(async_lib="asyncio") for task in self.async_tasks: task.cancel() @@ -94,7 +89,9 @@ async def run_wrapper(): oak0_client = EventClient(config) if oak0_client is None: - raise RuntimeError(f"No {config.name} service config provided in service_config.json") + raise RuntimeError( + f"No {config.name} service config provided in service_config.json" + ) # stream camera frames self.tasks: list[asyncio.Task] = [ @@ -119,6 +116,8 @@ async def stream_camera( SubscribeRequest(uri=Uri(path=f"/{view_name}"), every_n=rate), decode=False, ): + self.view_name = self.root.ids["tab_root"].current_tab.text + if view_name == self.view_name: message = payload_to_protobuf(event, payload) try: @@ -141,21 +140,6 @@ async def stream_camera( self.root.ids[view_name].texture = texture -def find_config_by_name( - service_configs: EventServiceConfigList, name: str -) -> EventServiceConfig | None: - """Utility function to find a service config by name. - - Args: - service_configs: List of service configs - name: Name of the service to find - """ - for config in service_configs.configs: - if config.name == name: - return config - return None - - if __name__ == "__main__": parser = argparse.ArgumentParser(prog="template-app") diff --git a/src/res/main.kv b/src/res/main.kv index 3b14249..6e2fb3a 100644 --- a/src/res/main.kv +++ b/src/res/main.kv @@ -2,24 +2,21 @@ RelativeLayout: TabbedPanel: pos_hint: {"x": 0.0, "top": 1.0} do_default_tab: False + id: tab_root TabbedPanelItem: - text: "Rgb" - on_press: app.update_view('rgb') + text: "rgb" Image: id: rgb TabbedPanelItem: - text: "Disparity" - on_press: app.update_view('disparity') + text: "disparity" Image: id: disparity TabbedPanelItem: - text: "Left" - on_press: app.update_view('left') + text: "left" Image: id: left TabbedPanelItem: - text: "Right" - on_press: app.update_view('right') + text: "right" Image: id: right Button: