OpenPivParams

A class for simple parameter handling.

This class is also used as a basis for automated widget creation by OpenPivGui.

class openpivgui.OpenPivParams.OpenPivParams

A class for convenient parameter handling.

Widgets are automatically created based on the content of the variables in the dictionary OpenPivParams.default.

The entries in OpenPivParams.default are assumed to follow this pattern:

(str) key:
[(int) index,
(str) type, value, (tuple) hints, (str) label, (str) help]

The index is used for sorting and grouping, because Python dictionaries below version 3.7 do not preserve their order. A corresponding input widget is chosen based on the type string:

None: no widget, no variable, but a rider boolean: checkbox str[]: listbox text: text area other (float, int, str): entry (if hints not None: option menu)

A label is placed next to each input widget. The help string is displayed as a tooltip.

The parameter value is directly accessible via indexing the base variable name. For example, if your OpenPivParams object variable name is »my_settings«, you can access a value by typing:

my_settings[key]

This is a shortcut for my_settings.param[key]. To access other fields, use my_settings.label[key], my_settings.help[key] and so on.

add_parameters(param: dict) → None

splitting the dictionary for more convenient access outsourcing out of the init method was necessary to use it within the Add_In_Handler :param param: dictionary containing a list for each parameter :type param: dict :return: None

dump_settings(fname)

Dump parameter values to a JSON file.

Parameters:fname (str) – A filename.

Only the parameter values are saved. Other data like index, hint, label and help should only be defined in the default dictionary in this source code.

generate_parameter_documentation(group=None)

Return parameter labels and help as reStructuredText def list.

Parameters:group (int) – Parameter group. (e.g. OpenPivParams.PIVPROC)
Returns:str
Return type:A reStructuredText definition list for documentation.
load_settings(fname)

Read parameters from a JSON file.

Parameters:fname (str) – Path of the settings file in JSON format.

Reads only parameter values. Content of the fields index, type, hint, label and help are always read from the default dictionary. The default dictionary may contain more entries than the JSON file (ensuring backwards compatibility).