-
Hi guys, I want to sample a camera and update an imshow fig continuously. my failed attempt: `class CameraPage(rio.Component):
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Easy! Use the class MyRoot(rio.Component):
counter: int = 0
@rio.event.periodic(2)
async def _on_periodic(self) -> None:
self.counter += 1
await self.force_refresh()
def build(self) -> rio.Component:
return rio.Text(
f"Counter: {self.counter}",
justify="center",
) In general, threading is rarely needed, especially in modern codebases. All of Rio supports asynchrony, so |
Beta Was this translation helpful? Give feedback.
Easy! Use the
periodic
event. It will continuously fire until the component is garbage collectedIn general, threading is rarely needed, especially in modern codebases. All of Rio supports asynchrony, so
asyncio
tasks are almost always preferred over threads.