more loosely coupled (though gui can also display data from independent serverswhatever we call itthis model both avoids blocking the gui while tasks run and avoids potentially parallel updates to the gui itself as more concrete examplesuppose your gui needs to display telemetry data sent in real time from satellite over sockets (an ipc tool introduced in your program has to be responsive enough to not lose incoming databut it also cannot get stuck waiting for or processing that data to achieve both goalsspawn threads that fetch the incoming data and throw it on queueto be picked up and displayed periodically by the main gui thread with such separation of laborthe gui isn' blocked by the satellitenor vice versa--the gui itself will run independently of the data streamsbut because the data stream threads can run at full speedthey'll be able to pick up incoming data as fast as it' sent gui event loops are not generally responsive enough to handle real-time inputs without the data stream threadswe might lose incoming telemetrywith themwe'll receive data as it is sent and display it as soon as the gui' event loop gets around to picking it up off the queue--plenty fast for the real human user to see if no data is sentonly the spawned threads waitnot the gui itself in other scenariosthreads are required just so that the gui remains active during longrunning tasks while downloading reply from web serverfor exampleyour gui must be able to redraw itself if covered or resized because of thatthe download call cannot be simple function callit must run in parallel with the rest of your program-typicallyas thread when the result is fetchedthe thread must notify the gui that data is ready to be displayedby placing the result on queuethe notification is simple--the main gui thread will find it the next time it checks the queue in its timer callback function for examplewe'll use threads and queues this way in the pymailgui program in to allow multiple overlapping mail transfers to occur without blocking the gui itself placing data on queues whether your guis interface with satelliteswebsitesor something elsethis threadbased model turns out to be fairly simple in terms of code example - is the gui equivalent of the queue-based threaded program we met earlier in (compare this with example - in the context of guithe consumer thread becomes the gui itselfand producer threads add data to be displayed to the shared queue as it is produced the main gui thread uses the tkinter after method to check the queue for results instead of an explicit loop example - pp \gui\tools\queuetest-gui py gui that displays data produced and queued by worker threads import _threadqueuetime dataqueue queue queue(infinite size gui coding techniques