A Parameter is the basic unit of data in a parameter tree. Each parameter has a name, a type, a value, and several other properties that modify the behavior of the Parameter. Parameters may have parent / child / sibling relationships to construct organized hierarchies. Parameters generally do not have any inherent GUI or visual interpretation; instead they manage ParameterItem instances which take care of display and user interaction.
Note: It is fairly uncommon to use the Parameter class directly; mostly you will use subclasses which provide specialized type and data handling. The static pethod Parameter.create(...) is an easy way to generate instances of these subclasses.
For more Parameter types, see ParameterTree.parameterTypes module.
Signals: | |
sigStateChanged(self, change, info) | Emitted when anything changes about this parameter at all. The second argument is a string indicating what changed (‘value’, ‘childAdded’, etc..) The third argument can be any extra information about the change |
sigTreeStateChanged(self, changes) | Emitted when any child in the tree changes state (but only if monitorChildren() is called) the format of changes is [(param, change, info), ...] |
sigValueChanged(self, value) | Emitted when value is finished changing |
sigValueChanging(self, value) | Emitted immediately for all value changes, including during editing. |
sigChildAdded(self, child, index) | Emitted when a child is added |
sigChildRemoved(self, child) | Emitted when a child is removed |
sigParentChanged(self, parent) | Emitted when this parameter’s parent has changed |
sigLimitsChanged(self, limits) | Emitted when this parameter’s limits have changed |
sigDefaultChanged(self, default) | Emitted when this parameter’s default value has changed |
sigNameChanged(self, name) | Emitted when this parameter’s name has changed |
sigOptionsChanged(self, opts) | Emitted when any of this parameter’s options have changed |
Add another parameter to the end of this parameter’s child list.
Used to temporarily block and accumulate tree change signals. You must remember to unblock, so it is advisable to use treeChangeBlocker() instead.
Return the path of parameter names from self to child. If child is not a (grand)child of self, return None.
Return a list of this parameter’s children.
Remove all child parameters.
Create a new Parameter (or subclass) instance using opts[‘type’] to select the appropriate class.
Use registerParameterType() to add new class types.
Return the default value for this parameter.
Return a tree of all values that are children of this parameter
Returns True if this parameter has a default value.
Hide this parameter. It and its children will no longer be visible in any ParameterTree widgets it is connected to.
Insert a new child at pos. If pos is a Parameter, then insert at the position of that Parameter. If child is a dict, then a parameter is constructed as Parameter(**child)
Return True if this parameter type matches the name typ. This can occur either of two ways:
Return a TreeWidgetItem suitable for displaying/controlling the content of this parameter. Most subclasses will want to override this function.
Return a child parameter. Accepts the name of the child or a tuple (path, to, child)
Return the parent of this parameter.
This method is called when the parameter’s parent has changed. It may be useful to extend this method in subclasses.
Remove this parameter from its parent’s child list
Remove a child parameter.
Restore the state of this parameter and its children from a structure generated using saveState() If recursive is True, then attempt to restore the state of child parameters as well. If addChildren is True, then any children which are referenced in the state object will be created if they do not already exist. If removeChildren is True, then any children which are not referenced in the state object will be removed. If blockSignals is True, no signals will be emitted until the tree has been completely restored. This prevents signal handlers from responding to a partially-rebuilt network.
Return a structure representing the entire state of the parameter tree. The tree state may be restored from this structure using restoreState()
Set the default value for this parameter.
Set limits on the acceptable values for this parameter. The format of limits depends on the type of the parameter and some parameters do not make use of limits at all.
Attempt to change the name of this parameter; return the actual name. (The parameter may reject the name change or automatically pick a different name)
Set any arbitrary options on this parameter. The exact behavior of this function will depend on the parameter type, but most parameters will accept a common set of options: value, name, limits, default, readonly, removable, renamable, visible, and enabled.
Set this parameter’s value to the default.
Show this parameter.
Return an object that can be used to temporarily block and accumulate sigTreeStateChanged signals. This is meant to be used when numerous changes are about to be made to the tree and only one change signal should be emitted at the end.
Example:
with param.treeChangeBlocker():
param.addChild(...)
param.removeChild(...)
param.setValue(...)
Called when the state of any sub-parameter has changed.
Arguments: | |
param | The immediate child whose tree state has changed. note that the change may have originated from a grandchild. |
changes | List of tuples describing all changes that have been made in this event: (param, changeDescr, data) |
This function can be extended to react to tree state changes.
Unblocks enission of sigTreeStateChanged and flushes the changes out through a single signal.
Returns True if this parameter’s value is equal to the default value.
Returns True if this parameter’s value can be changed by the user. Note that the value of the parameter can always be changed by calling setValue().