I have a python script that I input into the label expression by hand which assigns different labels depending on the attribute data, see:
def FindLabel ( [a], [b] ):
if [b] != 'ok' and [b] != 'missing' and [b] != 'not transmitting':
return "<CLR red = '255' green = '170'>" + [a] + " " + [b] + "</CLR>"
elif [b] == 'missing':
return "<CLR red = '130' green = '130' blue = '130'>" + [a] + " " + "Missing" + "</CLR>"
elif [b] == 'not transmitting':
return "<CLR red = '255'>" + [a] + " " + "Not Transmitting" + "</CLR>"
else:
return [a]
Is it possible to use arcpy to apply this label expression to a layer using labelClasses.expression, or any other method? The help page hints at the possibility by saying of the .expression method:
Provides the ability to get or set a layer's individual label class expression. This can be as simple as a single field or more advanced using either a VBScript, JScript or Python expression.
but I've never seen a working version.