Update GUI via Asynchronous thread

Since this sort of thing pops up often, I created a set of wrappers that simplify this stuff, and allows you to directly use functions in your script modules. The wrappers take care of stuffing the arguments you supply into a temporary fuction’s default argument.
For your case, try assignLater(). Nick’s example becomes:

# In a script module in your project:
import shutil
def fileTransfer(label):
   path = system.file.openFile()
   newPath = "F:\NewFolder"
   shutil.copy2(path, newPath)
   shared.assignLater(label, "text", "Step one done")
# In your button event
label = event.source.parent.getComponent("Label")
shared.later.callAsync(project.module.fileTransfer, label)

later.py (12 KB)
{ Updated link to point to a permanent location @ automation-pros.com }

3 Likes