|
class ControlMeta(type): |
|
''' |
|
Metaclass which creates CtlProperty objects for Control classes |
|
''' |
|
CONTROL_ATTRIBS = ['annotation', 'backgroundColor', 'defineTemplate', 'docTag', |
|
'dragCallback', 'dropCallback', 'enable', 'enableBackground', |
|
'exists', 'fullPathName', 'height', 'manage', 'noBackground', |
|
'numberOfPopupMenus', 'parent', 'popupMenuArray', 'preventOverride', |
|
'useTemplate', 'visible', 'visibleChangeCommand', 'width'] |
|
|
|
|
|
def __new__(cls, name, parents, kwargs): |
|
|
|
CMD = kwargs.get('CMD', None) |
|
_ATTRIBS = kwargs.get('_ATTRIBS',[]) # unique props from outer class |
|
|
|
if not kwargs.get('CMD'): |
|
CMD = parents[0].CMD |
|
|
|
for item in ControlMeta.CONTROL_ATTRIBS: |
|
kwargs[item] = CtlProperty(item, CMD) |
|
|
|
for item in _ATTRIBS: # now add in the outer class's unique props too |
|
kwargs[item] = CtlProperty(item, CMD) |
|
|
|
return super(ControlMeta, cls).__new__(cls, name, parents, kwargs) |
|
|
|
|
|
class MetaButton(object): |
|
CMD = cmds.button |
|
_ATTRIBS = ['label', 'command'] # button specific props |
|
__metaclass__ = ControlMeta |
|
|
|
def __init__(self, *args, **kwargs): |
|
self.Widget = self.CMD (*args, **kwargs) |
|
|
|
class MetaFloatField(object): |
|
CMD = cmds.floatField |
|
_ATTRIBS = ['editable','precision','value','maxValue','step', |
|
'minValue', 'changeCommand','dragCommand','enterCommand', |
|
'receiveFocusCommand'] # this one has a lot of properties |
|
|
|
__metaclass__ = ControlMeta |
|
|
|
def __init__(self, *args, **kwargs): |
|
self.Widget = self.CMD (*args, **kwargs) |