Background color

Sometimes it’s useful to highlight input fields in the property palette where an input is required and the value is missing or incorrect. This can be achieved by adding the following tag to the parameter node:

<BackgroundColor>(0, 255, 0)</BackgroundColor>

../../../_images/BackgroundColor.png

The value for these tag must be a tuple with a red, green and blue part like (0, 255, 0) and the range is between 0 and 255. To get the default background color, the tuple must be set to (-1, -1, -1).

The background color value can also be set by a Python condition in a single line. Because the pyp file uses the xml syntax, for the < and > operators the xml syntax &lt; and &gt; must be used.

<BackgroundColor>(0, 0, 255) if Double &lt; 50 else (-1, -1, -1)</BackgroundColor>

or in a multi line Python condition returning the color like

<BackgroundColor>
    if Double &lt; 1000:
        return (0, 255, 0)

    return (0, 0, 255)
<BackgroundColor>

The Python source code for the condition must be left aligned in the pyp file.

A use of the BackgroundColor is shown in the example

…\etc\Examples\PythonParts\PaletteExamples\AllControls.pyp
…\etc\PythonPartsExampleScripts\PaletteExamples\AllControls.py