Python Forum

Full Version: Worker thread?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
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...