Apr-15-2020, 05:06 PM
To run in a separate thread you will need 1 function that will do all the work. It should grab all the values it needs, maybe disable the pushbutton, draw the progress bar and cancel button, perform all the work, erase the progress bar and cancel button, and enable the pushbutton. In the simplified example below this is the "thread_func". The "button_func" is the function that is called when the button is pressed.
Things may be as simple as:
Things may be as simple as:
def thread_func(a1, a2, a3): Disable pushbutton Draw progress bar and cancel button Call functions that do the work Erase the progress bar and cancel button Enable pushbutton def button_func(): x = threading.Thread(target=thread_func, args=(a1, 2, a3)) # Whatever args to pass x.startThe cancel button would set some flag that the processing code would monitor. You can kill a thread, but it is better to let the application exit gracefully. The worker code will also have to update the progress bar periodically.