Created
March 19, 2014 00:00
-
-
Save theodox/9632729 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ControlMeta(type): | |
''' | |
Metaclass which creates CtlProperty and CallbackProperty objects for Control classes | |
''' | |
def __new__(cls, name, parents, kwargs): | |
CMD = kwargs.get('CMD', None) | |
_READ_ONLY = kwargs.get('_READ_ONLY',[]) | |
_ATTRIBS = kwargs.get('_ATTRIBS',[]) | |
_CALLBACKS = kwargs.get('_CALLBACKS',[]) | |
if not kwargs.get('CMD'): | |
CMD = parents[0].CMD | |
for item in _READ_ONLY: | |
kwargs[item] = CtlProperty(item, CMD, writeable = False) | |
for item in _ATTRIBS: | |
kwargs[item] = CtlProperty(item, CMD) | |
for item in _CALLBACKS: | |
kwargs[item] = CallbackProperty(item) | |
return super(ControlMeta, cls).__new__(cls, name, parents, kwargs) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment