ID 385311 - String parameter using Mapping Popup Menu widget can be set to an unavailable option via Python without a warning icon being displayed

Follow

Problem summary

When using a Mapping Popup Menu widget to display a parameter, a warning icon is typically shown to alert the user when a value they have chosen (for example by setting it via Python) is not one of the options provided:

However, for String parameters displayed using Mapping Popup Menu widgets, this warning icon is not shown if the value is set to a string that is used as a key in the options hint dictionary.

For example, when mapping the display values a, b and c onto the actual values x, y and z, the XML representation of the string parameter is as follows:

<string_parameter hints="{'options__order': ['a', 'b', 'c'], 'widget': 'mapper', 'options': {'a': 'x', 'c': 'y', 'b': 'z'}}" name="newParameter" value="x"/>

When setting the value of such a parameter via Python and the value is specified as anything that's not part of the available options, this parameter is displayed in the UI as follows:

However, if the value is set to a display name instead of a value as specified in the hints dictionary, this is not marked in the UI. 

If setting the parameter value in this example to either "a" or "x" via Python results in the parameter value being shown in the UI as "a", but the underlying parameter value being different:

>>> NodegraphAPI.GetNode('Group').getParameter('user.newParameter').getValue(0)a

vs

>>> NodegraphAPI.GetNode('Group').getParameter('user.newParameter').getValue(0)x

Customer reported version
Katana 3.1v2

Customer reported platform
CentOS 6

Steps to reproduce

  1. Create a Group node and set its Edit flag.
  2. Open the wrench menu and select "Edit User Parameters".
  3. Add a new String user parameter.
  4. Click on the new parameter's wrench menu and under 'Widget Type' select 'Mapping Popup Menu'.
  5. In the same Wrench menu, select 'Widget Options'.
  6. In the dialog that pops up, add a few entries under Popup Options, for example as shown below, and click OK:
    ​​
  7. Set the parameter value to "a" using the dropdown in the UI and inspect the value via Python using the code snippet below. Note that the value is set to "x".

    NodegraphAPI.GetNode('Group').getParameter('user.newParameter').getValue(0)

  8. Use the following Python code to set the value to "a":

    NodegraphAPI.GetNode('Group').getParameter('user.newParameter').setValue("a", 0)

Expected behaviour
The value of the parameter is set to "a". A warning icon appears in the Parameters tab to indicate that the current parameter value is not an available option.

Actual behaviour
The value of the parameter is set to "a". There is no warning icon in the Parameters tab to alert the user that the value they have chosen is unavailable.

Workaround
Before setting the value of a Mapping Popup parameter via Python, verify the available value options by looking at the widget options in the XML representation of the parameter, for example as follows:

NodegraphAPI.GetNode('Group').getParameter('user.newParameter').getXML()

Note that it may be necessary to supply strings containing integers as the value if the parameter is of type String.

Reproduced by support
Katana 3.1v3 - CentOS 7 - Windows 10
Katana 3.0v8 - CentOS 7 - Windows 10
Katana 3.0v1 - CentOS 7 - Windows 10
Katana 2.5v1 - CentOS 7 - Windows 10
Katana 2.0v1 - CentOS 7
Katana 1.6v3 - CentOS 7

    We're sorry to hear that

    Please tell us why