python textual - run a loop besides the main loop

175 Views Asked by At

I'm using textual to display a ui in my console window. I start my class extending textual's App class by myclass.run(). Since I'm analyzing a camera signal using opencv, I now want to introduce a second loop that runs as long as the app runs to get and process the current image from opencv. But I'm not sure how to start such a parallel loop using textual's API. The first thing that comes to my mind is a subthread but I fear textual might offer a better way.

1

There are 1 best solutions below

2
On

Textual offers a Worker API, which provides a layer over threads to manage concurrent work. By the sounds of it, you want a threaded worker.