Component Extension Functions

Some advanced components can be customized by using the extension functions. These functions will be called by the component itself when appropriate. For example, the Power Table component exposes an extension function called getBackgroundColorAt(). By implementing this function, you can control the background color of each cell of the table component using scripting.

Extension functions allow you in a loose sense to create a custom "sub-class" of the base component type, from an object-oriented point of view. Your sub-class can then override/implement parts of the functionality of the component itself, in python. This is a very powerful, if somewhat advanced, way of configuring the component. Each component extension function comes with its own documentation built-into the function's default implementation using a standard Python "doc-string". You will find that you are unable to edit the function's signature or docstring. Changing the method's signature (arguments or function name) would prevent the component from calling it correctly. Changing the docstring could be misleading or confusing as you'd lose the documentation for how your implementation of the function should work.

Following Python object-oriented methodology, you'll notice that each extension function's first argument is called "self". That is because these are methods belong to the component's class itself. That is, they are instance methods. The value of self will always be the component itself. Notice that this is different than component event handler scripts. In those scripts, you are given an event object in your scope. The component that fired the event will be under event.source. When you write an extension function, there is no event object. The component is given to you as the self object instead.