arcpy add-in progress bar

4268
3
Jump to solution
10-16-2015 01:05 PM
ShaunConway
Occasional Contributor II

Is it possible to add a progress bar to an ArcPy Add-in in ArcGIS 10.2.2?  I've tried adding the following code to the add-in with out any success.

arcpy.SetProgressor("step", "Copying shapefiles to geodatabase...", 0, 10, 1)

and

arcpy.SetProgressorPosition()

I have an add-in that updates a series of feature classes that takes anywhere from 30 secs to a few minutes depending on the machine. A progress bar would be a great addition to the tool from a UX perspective.

Thanks!

Shaun

0 Kudos
1 Solution

Accepted Solutions
FreddieGibson
Occasional Contributor III

It's my understanding that the progressor you both mentioned about is only applicable to the Geoprocessing framework. I don't believe this carriers over for addins. You may have to post an idea for this functionality at ideas.arcgis.com.

Otherwise, I'm looking through the documentation for python addins and I don't see anything that would allow you to either build the UI element needed for the progress bar or anything that would allow you store the progressbar on a toolbar. If you were to use ArcObjects you could get away with a modal window that hosts the progressbar, but I don't see any interfaces available that would allow you to store the ui component on the toolbar.

View solution in original post

3 Replies
FreddieGibson
Occasional Contributor III

It's my understanding that the progressor you both mentioned about is only applicable to the Geoprocessing framework. I don't believe this carriers over for addins. You may have to post an idea for this functionality at ideas.arcgis.com.

Otherwise, I'm looking through the documentation for python addins and I don't see anything that would allow you to either build the UI element needed for the progress bar or anything that would allow you store the progressbar on a toolbar. If you were to use ArcObjects you could get away with a modal window that hosts the progressbar, but I don't see any interfaces available that would allow you to store the ui component on the toolbar.

RebeccaStrauch__GISP
MVP Emeritus

If you have a total count and are looping thru the process, you can always use a simple arcpy.AddMessage to keep track.  This isn't as clean as trying to get something in the process/status area, but it works if you look a the messages in the result tab.  Nothing fancy, but it will give you some indication of progress.

import arcpy
ws = r'C:\test\New File Geodatabase.gdb'
arcpy.env.workspace = ws
lstFC = arcpy.ListFeatureClasses()   # modify this for your FC type, as needed
cntTotal = len(lstFC)
print("{0} FC to process".format(cntTotal))  # use arcpy.AddMessage in script instead of print
cntRemain = cntTotal
for fc in lstFC:
     # do somethin here
     print(fc)
     cntRemain -= 1
     print("{0} of {1} remaining".format(cntRemain, cntTotal))