SetProgressor (arcpy)

摘要

建立一个进度条对象将进度信息传递至进度对话框。可通过选择默认进度条或步长进度条来控制进度对话框的外观。

语法

SetProgressor (type, {message}, {min_range}, {max_range}, {step_value})
参数说明数据类型
type

The progressor type (default or step).

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

(默认值为 default)

String
message

The progressor label. The default is no label.

String
min_range

Starting value for progressor. Default is 0.

(默认值为 0)

Integer
max_range

Ending value for progressor. Default is 100.

(默认值为 100)

Integer
step_value

The progressor step interval for updating the progress bar.

(默认值为 1)

Integer

代码实例

SetProgressor 示例

设置进度条对象以在进度对话框中显示进度。

import os
import arcpy

# Allow overwriting of output
arcpy.env.overwriteOutput = True

# Set current workspace
arcpy.env.workspace = "c:/data"

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

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

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

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

# For each shapefile, copy to a file geodatabase
for shp in fcs:
    # Trim the '.shp' extension
    fc = os.path.splitext(shp)[0]

    # Update the progressor label for current shapefile
    arcpy.SetProgressorLabel("Loading {0}...".format(shp))

    # Copy the data
    arcpy.CopyFeatures_management(shp, os.path.join("fgdb.gdb", fc))

    # Update the progressor position
    arcpy.SetProgressorPosition()

arcpy.ResetProgressor()

相关主题

5/10/2014