Python Forum
Worker thread? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Worker thread? (/thread-2214.html)



Worker thread? - micko - Feb-27-2017

My program does the following:
SQL query results based on GUI (user filled) data is passed to TCPprinter thread in arguments. I'm using threading because I need to check printer(s) state and don't want to freeze the GUI. However GUI will only show status info until the TCPprinter thread is finished. After that user is allowed to enter new data and start printing thread again.

Should I use queue instead and keep my TCPprinter thread running as long as GUI is alive, or is there some better approach?


RE: Worker thread? - Ofnuts - Feb-27-2017

Your GUI thread would have to polls some common variable, but polling is not possible in a GUI (unless you have a manual "refresh" button). The other (and most common) solution is to have the printer thread notify the GUI thread. But this requires the printer thread to be able to send some event to the GUI even loop. Most GUI libraries support this, except tkinter...