摘要
在上下文管理器中使用地图视图时暂停地图视图的绘制。
说明
PauseDrawing 类是一个上下文管理器,在将更新应用于图层时,此类可用于暂停地图视图的绘制。 即使在 PauseDrawing 上下文管理器中调用 RefreshLayer 函数,地图视图也不会进行刷新,直到退出 with 块为止。
语法
PauseDrawing ()
代码示例
当使用更新游标应用更新时,可使用 PauseDrawing 类作为上下文管理器。
import arcpy
from random import randint
featureclass_1 = r"c:\data\myGDB.gdb\fc1"
featureclass_2 = r"c:\dat\myGDB.gdb\fc2"
with arcpy.PauseDrawing():
with arcpy.da.UpdateCursor(featureclass_1, "class") as cursor:
for row in cursor:
classification = randint(1, 5)
row[0] = classification
cursor.updateRow(row)
with arcpy.da.UpdateCursor(featureclass_2, "class") as cursor:
for row in cursor:
classification = randint(1, 5)
row[0] = classification
cursor.updateRow(row)
arcpy.RefreshLayer((featureclass_1, featureclass_2))
# The map view will refresh now that the PauseDrawing context manager has closed.