Can The Main Loop Of A Program Be Moved Out Of GUI?
Solution 1:
Why not seperate your logic and presentation. Write your sim backend to respond to a single text based protcol to receive cmds and send back results, and then just talk to it from your gui program over e.g. unix sockets.
Solution 2:
Write your own main loop that calls the functions that check for and process GUI events.
Solution 3:
In this case, you should perform your processing in a separate thread, and then have the GUI thread send and receive messages to that thread.
However, do not try to directly update the GUI from the processing thread. Instead, you can send a message to the GUI using a message queue, similar to effbot's example. The important thing is queue.get_nowait()
: you can just periodically run this in your GUI without blocking other threads if there is nothing in the queue.
Post a Comment for "Can The Main Loop Of A Program Be Moved Out Of GUI?"