I want to write a program that will constantly compute numbers, and draw on the window canvas, including drawing text and setting pixels. So the program probably cannot go into an event loop (the main_loop), because that will stop the computation of numbers.
Is there a way just to draw the items without an event loop?
Or, should a thread be created, so that one thread will do the computation, and one thread handles the window's event loop?
The general strategy for event-based programs that must do long calculations is one of the following:
The first method is ideal if you can manage it. My personal preference then goes to the third method. IMO threads should be avoided if at all possible, unless you fully grok threaded programming (and even then I still usually recommend a separate process).