Params

Param

class datavis.models.Param(paramName, paramType, **kwargs)

Define basic properties of a parameter to be used in different contexts.

This class is used by PickerModel class to define parameters that can be changed by the user in the GUI.

__init__(paramName, paramType, **kwargs)

Create a new instance.

Parameters
  • paramName – Name of the param.

  • paramType – Type of the param

Keyword Arguments
  • value – the initial value of the param

  • range – (min, max) tuple if the type is ‘int’ or ‘float’

  • label – the label to be used for display

  • help – extra help message to be shown to the user

  • display – optional tip about how to display this param, options: * default: the default for each type, most of types is textbox * combo, hlist, vlist for type ‘enum’ * slider for type ‘int’ or ‘float’ if range is defined

Examples:

# Enum param with many options, default display 'combo'
job = Param('job', dv.models.PARAM_TYPE_ENUM, label='Job',
            choices=['Student', 'Unemployed', 'Academic', 'Industry', 'Other'])

# Another enum, but displayed as horizontal list (hlist)
gender = Param('gender', dv.models.PARAM_TYPE_ENUM, label='Gender',
               choices=['Male', 'Female'],
               display=dv.models.PARAM_DISPLAY_HLIST)

# Integer param with a given range, default display 'slider'
happy = Param('happy', dv.models.PARAM_TYPE_INT, label='Happiness',
              range=(1, 10), value=5,
              help='Select how happy you are in a scale from 1 to 10')
static load(paramDict)

Create a new Param from the dict description.

set(**kwargs)

Set any of the attributes of this param.

Form

class datavis.models.Form(paramsList)

Simple container of several params with a given layout.

__init__(paramsList)

Create a new Form instance.

Parameters

paramsList – the parameters list that specify how they the params will be arranged in the GUI. Each item in the list will be placed in a separated row. A list of params can be used to group many params in the same row.

Examples:

f = Form([param1,
          param2,
          [param3, param4, param5]
         ])
static load(paramDictList)

Creates a new Form from the description from a list of dict.

Parameters

paramDictList – A list of dicts, describing each param. Each entry of the list will be a row. Multiple params can be grouped into the same row by using another list.

Returns

A new Form instance.

Examples:

pickerParams = [
    {
        'name': 'threshold',
        'type': 'float',
        'value': 0,
        'range': (0., 1),
        'label': 'Quality threshold',
        'help': 'Quality threshold',
        'display': 'slider'
    },
    {
        'name': 'radius',
        'type': 'int',
        'value': self._radius,
        'range': (1, int(self._imageSize[0]/3)),
        'label': 'Radius',
        'help': 'Radius',
        'display': 'slider'
    }
]

form = dv.models.Form.load(pickerParams)