SetProgressor

Récapitulatif

Establishes a progressor object which allows progress information to be passed to a progress dialog box. The appearance of the progress dialog box can be controlled by choosing either the default progressor or the step progressor.

Syntaxe

SetProgressor (type, {message}, {min_range}, {max_range}, {step_value})
ParamètreExplicationType de données
type

The progressor type (default or step).

  • defaultThe progressor moves back and forth continuously.
  • stepThe progressor shows the percentage complete.

(La valeur par défaut est default)

String
message

The progressor label. The default is no label.

String
min_range

Starting value for progressor. Default is 0.

(La valeur par défaut est 0)

Integer
max_range

Ending value for progressor. Default is 100.

(La valeur par défaut est 100)

Integer
step_value

The progressor step interval for updating the progress bar.

(La valeur par défaut est 1)

Integer

Exemple de code

SetProgressor example

Set progressor object for displaying progress in the progress dialog box.

import arcpy
from arcpy import env

# Allow overwriting of output 
# 
env.overwriteOutput = True
 
# Set current workspace 
# 
env.workspace = "c:/data" 

# Get a list of shapefiles in folder 
# 
fcs = arcpy.ListFeatureClasses() 

# Find the total count of shapefiles in list 
# 
fcCount = len(fcs) 

# Set the progressor 
#
arcpy.SetProgressor("step", "Copying shapefiles to geodatabase...", 0,fcCount, 1) 

# Create a file gdb to contain new feature classes 
#
arcpy.CreateFileGDB_management(env.workspace, "fgdb.gdb") 

# For each shapefile, copy to a file geodatabase 
# 
for shp in fcs: 
    # Trim the '.shp' extension 
    # 
    fc = shp.rstrip(".shp") 

    # Update the progressor label for current shapefile 
    # 
    arcpy.SetProgressorLabel("Loading " + shp + "...") 

    # Copy the data 
    # 
    arcpy.CopyFeatures_management(shp, "fgdb.gdb/" + fc) 
 
    # Update the progressor position 
    # 
    arcpy.SetProgressorPosition()

arcpy.ResetProgressor()

Rubriques connexes


7/10/2012