Extensions#
extendable#
- tkclasswiz.extensions.extendable(obj: T | list) T#
Decorator that makes the obj extendable.
It wraps the
obj, which is a class or a function, into an extension object. The extension object will adds 3 methods to the original class or function:register_pre_extensionregister_post_extensionget_extensions
The
get_extensionsmethod just returns the list of registered extensions (tkclasswiz.extensions.Extension).The
register_pre_extensionandregister_post_extensionmethods allow users to extend the functionality of original tkclass wiz classes or functions. They accept the extension (tkclasswiz.extensions.Extension) parameter.Pre-extensions (
register_pre_extension) get activated / called before the original__init__method / before the original function and accept theloaderof the extension must accept the same arguments as the original__init__method / original function.Post-extensions differ a bit if the thing being extended is a class or a function. They both have in common that they get activated after the original
__init__method call / original function call, but they differ in the arguments they receive:In the case of the extended is a class, the extension
loaderaccepts the same arguments as the__init__method receives.In the case of the extended is a function, the extension
loaderaccepts the same arguments as the original function and an additional parameter, which is the result of the original function call. The result parameter is passed to theloaderas the last positional argument.
- Parameters:
obj (T) – Function or a class that can be extended.