Best way to display processing progress from importer addon?

I’m trying to make my importer addon a bit more user friendly by providing some sort of user feedback while it is processing (i.e. displaying something along the lines of ‘Reading: 80%…’) that will be updated periodically during the import to let the user know what’s going on. I tried calling{‘INFO’}, …) but the UI never displays it. I assume that’s because I go right back to importing which pegs the UI thread (a guess). So what is the recommended way to provide user feedback during a lengthy processing operation in Python?

It’s covered here:
How to show to the user a progression in a script?

Note that the UI is locked until your script finishes.

On Windows, there’s a problem with the cursor progress indicator: if the user clicks twice on the Blender window, it will be recognized as hanging by the OS (indicated by a fade to duller colors of the last window content) and the cursor is replaced by the default indeterminate waiting cursor (spinning ring, hourglass or whatever) - so you effectively lose the actual progress indicator.

Thanks codemanx, that explains the issue and my option.

Can anyone confirm that using the wm.progress_update() method is resource intensive? It’s slaughtering the performance of my importer by about 400% or more. I’m handling some heavy data (millions of verts in most cases) and when I tried to use this for progress indication, it quadrupled the time it took for my importer to run.

Here’s some quick comparisons with and without using wm.progress_update() …

881112 verts imported.
Without: 41.32 seconds
With: 228.18 seconds

I don’t think this is a viable solution. I’ve tested this several times on different files, and I’m getting the same results. And for the record, I’m on a MacBook Pro running OS X 10.10 GM3 with 8GB of RAM and a 2.3 GHz Intel Core i7. I’ve tested this on my wife’s iMac running OS X 10.9 and got similar results as well.

I’m not very familiar with bgl, but could we draw our own progress indicators on the screen?

how (often) do you update the progress indicator?

Are there any print() statements in your script?

Sorry, I must have been really tired last night (studying for midterms) and was updating it on every iteration of the loop. I suppose it would be much more efficient to update on every 10% or so with …

maxNumPoints = f.header.count
currentPoint = 0
wm = bpy.context.window_manager
wm.progress_begin(0, maxNumPoints/10)

for point in f:
    if maxNumPoints > 0:

      # import code here. example is importing XYZ coords from p into list coords[]
      coords.append(point.x, point.y, point.z)

      if (((currentPoint/maxNumPoints)*100)%10 == 0):

      currentPoint +=1
      maxNumPoints -= 1


Re-executed some imports on some semi-large datasets and it’s back to normal now. Also, on Mac OS X, all this really does change the curser to a beachball, so you could essentially just not update until the end and it achieves the same effect. I’m still kind of interested in building a simple bgl solution with a few rects to make a simple progress bar. This might not be possible if Blender is locking the UI during import, though.