It is possible to create your own node classes in python and insert them into libavg scenes. This is a powerful abstraction mechanism, because it allows you to define reusable visual and user interface elements easily. libavg does this internally in several cases: Several of the more specific node classes like RoundedRect and Keyboard are implemented in pure python.

As you can see, TextRect is derived from DivNode. The constructor takes any arguments specific to TextRect, forwards all other keyword arguments (**kwargs) to the base class and calls registerInstance() on itself to set up the C++ base class properly. It then creates the child nodes, centering the text inside the rectangle.