A NotificationForwarder object can be used to forward slot events from one particular slot to an arbitrary method instead of the onValueChanged() or onResize() method. To accomplish this the NotificationForwarder object is added as a dependent object of the slot. This means, whenever the value of the slot changes, the onValueChanged() method of the NotificationForwarder object is called which in turn calls an arbitrary other function or method.
| onvalchanged, onresize=None) |
onvalchanged is an arbitrary callable object that is invoked whenever a value changed event has occured. If the forwarder is used with a normal slot, the callable does not take any arguments. If it is used with an array slot, it takes two arguments start and end that specify what range has been modified.
onresize is a callable that gets called whenever the size of an array slot has changed. It takes one argument which is the new size of the slot.
Example:
>>> from cgkit import * >>> def myCallback(): print "Something has happened" ... >>> s=Sphere() >>> n=NotificationForwarder(myCallback) >>> s.radius_slot.addDependent(n) Something has happened >>> s.radius=5 Something has happened >>> s.radius=2 Something has happened