- pyqtgraph.parametertree.registerParameterType(name, cls, override=False)[source]#
Register a parameter type in the parametertree system.
This enables construction of custom Parameter classes by name in
- pyqtgraph.parametertree.registerParameterItemType(name, itemCls, parameterCls=None, override=False)[source]#
registerParameterType(), but works on ParameterItems. This is useful for Parameters where the itemClass does all the heavy lifting, and a redundant Parameter class must be defined just to house itemClass. Instead, use registerParameterItemType. If this should belong to a subclass of Parameter, specify which one in parameterCls.
- class pyqtgraph.parametertree.Parameter(**opts)[source]#
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.
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
Emitted when any child in the tree changes state (but only if monitorChildren() is called) the format of changes is [(param, change, info), …]
Emitted when value is finished changing
Emitted immediately for all value changes, including during editing.
sigChildAdded(self, child, index)
Emitted when a child is added
Emitted when a child is removed
Emitted when this parameter is removed
Emitted when this parameter’s parent has changed
Emitted when this parameter’s limits have changed
Emitted when this parameter’s default value has changed
Emitted when this parameter’s name has changed
Emitted when any of this parameter’s options have changed
Emitted when a context menu was clicked
Initialize a Parameter object. Although it is rare to directly create a Parameter instance, the options available to this method are also allowed by most Parameter subclasses.
The name to give this Parameter. This is the name that will appear in the left-most column of a ParameterTree for this Parameter.
The value to initially assign to this Parameter.
The default value for this Parameter (most Parameters provide an option to ‘reset to default’).
A list of children for this Parameter. Children may be given either as a Parameter instance or as a dictionary to pass to Parameter.create(). In this way, it is possible to specify complex hierarchies of Parameters from a single nested data structure.
If True, the user will not be allowed to edit this Parameter. (default=False)
If False, any widget(s) for this parameter will appear disabled. (default=True)
If False, the Parameter will not appear when displayed in a ParameterTree. (default=True)
If True, the user may rename this Parameter. (default=False)
If True, the user may remove this Parameter. (default=False)
If True, the Parameter will initially be expanded in ParameterTrees: Its children will be visible. (default=True)
If True, the expanded state of this Parameter is synchronized with all ParameterTrees it is displayed in. (default=False)
(str or None) If specified, then the parameter will be displayed to the user using this string as its name. However, the parameter will still be referred to internally using the name specified above. Note that this option is not compatible with renamable=True. (default=None; added in version 0.9.9)
- addChild(child, autoIncrementName=None, existOk=False)[source]#
Add another parameter to the end of this parameter’s child list.
See insertChild() for a description of the autoIncrementName and existOk arguments.
Add a list or dict of children to this parameter. This method calls addChild once for each value in children.
Used to temporarily block and accumulate tree change signals. You must remember to unblock, so it is advisable to use treeChangeBlocker() instead.
Return a child parameter. Accepts the name of the child or a tuple (path, to, child)
Added in version 0.9.9. Earlier versions used the ‘param’ method, which is still implemented for backward compatibility.
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. Warning: this overrides QObject.children
- static create(**opts)[source]#
Static method that creates a new Parameter (or subclass) instance using opts[‘type’] to select the appropriate class.
All options are passed directly to the new Parameter’s __init__ method. Use registerParameterType() to add new class types.
Hide this parameter. It and its children will no longer be visible in any ParameterTree widgets it is connected to.
- insertChild(pos, child, autoIncrementName=None, existOk=False)[source]#
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 using
By default, the child’s ‘autoIncrementName’ option determines whether the name will be adjusted to avoid prior name collisions. This behavior may be overridden by specifying the autoIncrementName argument. This argument was added in version 0.9.9.
If ‘autoIncrementName’ is False, an error is raised when the inserted child already exists. However, if ‘existOk’ is True, the existing child will be returned instead, and this child will not be inserted.
Return True if this parameter type matches the name typ. This can occur either of two ways:
If self.type() == typ
If this parameter’s class is registered with the name typ
Return a TreeWidgetItem suitable for displaying/controlling the content of this parameter. This is called automatically when a ParameterTree attempts to display this Parameter. Most subclasses will want to override this function.
This method is called when the parameter’s parent has changed. It may be useful to extend this method in subclasses.
Return True if this parameter is read-only. (this is the opposite of writable())
- restoreState(state, recursive=True, addChildren=True, removeChildren=True, blockSignals=True)[source]#
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().
If filter is set to ‘user’, then only user-settable data will be included in the returned state.
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, enabled, expanded and syncExpanded.
Parameter.__init__for more information on default options.
Set whether this Parameter’s value may be edited by the user (this is the opposite of setWritable()).
- setValue(value, blockSignal=None)[source]#
Set the value of this Parameter; return the actual value that was set. (this may be different from the value that was requested)
Set whether this Parameter should be editable by the user. (This is exactly the opposite of setReadonly).
Return the title of this Parameter.
By default, the title is the same as the name unless it has been explicitly specified otherwise.
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.
with param.treeChangeBlocker(): param.addChild(...) param.removeChild(...) param.setValue(...)
- treeStateChanged(param, changes)[source]#
Called when the state of any sub-parameter has changed.
The immediate child whose tree state has changed. note that the change may have originated from a grandchild.
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.