What I am hoping to be able to achieve with this Tool within my Toolbox is to allow the user to input a number of layers and to set all of the labels with the same font settings (font style, color, size, etc.). I started with the font size. Within my getParameterInfo() function, I have defined the following parameters:
updlayers = arcpy.Parameter( displayName = "Layers with features to be updated", name = "updlayers", datatype = "GPValueTable", parameterType = "Required", direction = "Input") labelFontSize = arcpy.Parameter( displayName = "Label Font Size", name = "labelFontSize", datatype = "GPDouble", parameterType = "Required", direction = "Input")
Then, within my execute function, I have the following pieces of code:
updlayers = parameters.values labelFontSize = parameters.value for layers in updlayers: for labels in layers: labels.showLabels = True for a in labels.labelClasses: a.expression = '"%s" + [Name] + "%s"' % ("<BOL><FNT name='Arial' size='labelFontSize'>","</FNT></BOL>")
I know that my code works fine if I replace 'labelFontSize' to an actual numerical value. I also attempted to change my expression to instead use labelFontSize as a string:
a.expression = '"%s" + [Name] + "%s"' % ("<BOL><FNT name='Arial' size=str(labelFontSize)>","</FNT></BOL>")
However, for some reason, the label either doesn't appear at all or it shows the actual expression text as my label. The issue I am having with is obviously within the expression part of my code.
However, how do I apply my labelFontSize variable into this expression?
Am I going the correct route with this or is there an easier way to do this?