pymel.core.windows.valueControlGrp

valueControlGrp(name=None, create=False, dataType=None, slider=True, value=None, numberOfControls=1, **kwargs)

This function allows for a simplified interface for automatically creating UI’s to control numeric values.

A dictionary of keywords shared by all controls can be created and passed to this function and settings which don’t pertain to the element being created will will be ignore. For example, ‘precision’ will be ignored by all non-float UI and ‘sliderSteps’ will be ignore by all non-slider UIs.

Parameters:
dataType : string or class type

The dataType that the UI should control. It can be a type object or the string name of the type. For example for a boolean, you can specify ‘bool’ or pass in the bool class. Also, if the UI is meant to control an array, you can pass the type name as a stirng with a integer suffix representing the array length. ex. ‘bool3’

numberOfControls : int

A parameter for specifying the number of controls per control group. For example, for a checkBoxGrp, numberOfControls will map to the ‘numberOfCheckBoxes’ keyword.

slider : bool

Specify whether or not sliders should be used for int and float controls. Ignored for other types, as well as for int and float arrays

value : int, int list, bool, bool list, float, float list, string, unicode, Path, Vector,

The value for the control. If the value is for an array type, it should be a list or tuple of the appropriate number of elements.

A straightforward example:

settings = {}
settings['step'] = 1
settings['precision'] = 3
settings['vertical'] = True # for all checkBoxGrps, lay out vertically
win = window()
columnLayout()
setUITemplate( 'attributeEditorTemplate', pushTemplate=1 )
boolCtr = valueControlGrp( dataType='bool', label='bool', **settings)
bool3Ctr = valueControlGrp( dataType='bool', label='bool', numberOfControls=3, **settings)
intCtr = valueControlGrp( dataType=int, label='int', slider=False, **settings)
intSldr = valueControlGrp( dataType=int, label='int', slider=True, **settings)
int3Ctrl= valueControlGrp( dataType=int, label='int', numberOfControls=3, **settings)
floatCtr = valueControlGrp( dataType=float, label='float', slider=False, **settings)
floatSldr = valueControlGrp( dataType=float, label='float', slider=True, **settings)
pathCtrl = valueControlGrp( dataType=Path, label='path', **settings)
win.show()

Here’s an example of how this is meant to be used in practice:

settings = {}
settings['step'] = 1
settings['precision'] = 3
win = window()
columnLayout()
types=[ ( 'donuts?',
            bool,
            True ),
        # bool arrays have a special label syntax that allow them to pass sub-labels
        ( [ 'flavors', ['jelly', 'sprinkles', 'glazed']],
            'bool3',
            [0,1,0]),
        ( 'quantity',
          int,
          12 ),
        ( 'delivery time',
          float,
          .69)
        ]
for label, dt, val in types:
    valueControlGrp( dataType=dt, label=label, value=val, **settings)
win.show()