Loading bar during script execution


I 've created a python script which takes a few seconds to execute.
I would like to know if I can show a loading bar during my script execution ?


In general, any script in a GUI should run in < 0.1 second unless it’s put in the background. system.util.invokeAsynchronous() is the tool you need to kick off your script. However, from the background, it isn’t safe to interact with the UI at all (Like, lock up or crash the whole client). So your script must collect it’s results and pass them to a script called from system.util.invokeLater(), which will run in the GUI thread and can place your results into the target components. For a progress meter, you don’t have to wait for the end of the script – at various points within the script, use invokeLater() to update a bar graph or some other status object. Those updates would make it visible, set it’s percentage at various intervals, and make it invisible again. Or the starting script could open a popup window, pass that to the background script, and the background script would update the popup with invokeLater().
You might want to review this thread – I posted a script module “later.py” that has utility functions that make it easier to use the invoke*() functions.