I have a wx Gui that gathers all the necessary info and starts an external command line app. Whilst it is running my gui freezes as you'd expect so I've been experimenting with putting the external app in a thread of its own.
My original code ends with the line:
os.system(args)
args contains the path and parameters required. Works fine.
So here is the bit of threading code nicked from an online tutorial:
class AVCThread(Thread):
"""Test Worker Thread Class."""
#----------------------------------------------------------------------
def __init__(self):
"""Init Worker Thread Class."""
Thread.__init__(self)
self.start() # start the thread
#----------------------------------------------------------------------
def run(self):
"""Run Worker Thread."""
# This is the code executing in the new thread.
os.system(args)
wx.CallAfter(Publisher().sendMessage, "update", "Processing completed")
This will work if I make args a global and substitute AVCThread() for the original os.system(args). But that is limiting and, I believe, frowned upon. Otherwise how would I get the value of args from the Gui class into the thread class. Or am I approaching this all wrong. I haven't yet found a threads tutorial that is explicit enough... Thanks.