I work with several MXD files. In each map there a polygon layer with unique values:
I try to change in the table of contents the "a" into "land use" by using this code:
import arcpy,os,sys
from arcpy import env
env.workspace = r"G:\desktop\Project"
for mxdname in arcpy.ListFiles("*.mxd"):
print mxdname
mxd = arcpy.mapping.MapDocument(r"G:\desktop\Project\\" + mxdname)
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "*")[0]
if lyr.symbologyType == "UNIQUE_VALUES":
vals = lyr.symbology.classLabels
for v in vals:
if v == "a":
print lyr.name
v = 'landUse'
print v
mxd.save()
del mxd
I just want to change the name in the table of content, and not change the attribute table value. When running this code i get this result and with no change in the maps:
>>>
project.mxd
polygon
landUse
>>>