Value and ValueList

The <Value> tag defines the default value and the <ValueList> tag defines the possible values of the parameter. The values in the value list must be separated by the pipe | character, like

<ValueList>1.0|2.0|3.0|4.0</ValueList>

or can be created using a Python range command to create a Python list as follows

<ValueList>[value for value in range(0, RangeEnd + 1 , 5)]</ValueList>

The start, end and step value can be a fixed value or the name of an corresponding parameter. The value type of the list values must be the same as the value type of the parameter.

In case of an edit control, the input value is checked against the values from the <ValueList>. If the input value is not present in the value list, the input value is matched to the closest value from the value list.

Dynamic ValueList

The <ValueList> tag can contain conditions to create a dynamic value list. There are two ways to achieve this

  • use a conditional expression

    <ValueList>"500.|600|700" if WidthDimension == 1 else "1000|1200|1400" if WidthDimension == 2 else "1500|1800|2100"</ValueList>
    
  • write a multi line Python expression

    <ValueList>
      if HeightDimension == 1:
          return "700.|725|750|775"
      elif HeightDimension == 2:
          return "800|825|850|875"
      else:
          return "900|925|950|975"
    </ValueList>
    

    The expression must be written as Python code, functions from the math package are possible and can be used by math.xxx.

The Python source code for the condition must be left aligned in the pyp file. Because the pyp file uses the xml syntax, for the < and > operators the xml syntax &lt; and &gt; must be used.

The use of the dynamic value list is shown in the following example

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