-
Notifications
You must be signed in to change notification settings - Fork 2
Satish Goda edited this page Sep 21, 2016
·
1 revision
ict
sections = OrderedDict()
sections['body'] = {'type': 'section',
'width': 800,
'height': 800,
'elements': { 'item1': {
'type': 'circle',
'color': 'red',
'opacity': 0.7,
'text': 'Arms Fk Ik'
},
'item2': {
'type': 'rect',
'color': 'blue',
'opacity': 0.9,
'text': 'All'
},
'item3': {
'type': 'svg',
'color': 'green',
'opacity': 0.5,
'text': 'Toggle'
}
}
}
sections['head'] = {'type': 'section',
'width': 1024,
'height': 1024,
'elements': { 'item1': {
'type': 'ellipse',
'color': 'pink',
'opacity': 0.9,
'text': 'Face Ctrls'
},
'item2': {
'type': 'svg',
'color': 'cyan',
'opacity': 1,
'text': 'Whiskers'
},
}
}
##
class Adapter(dict):
__getattr__ = dict.__getitem__
def __init__(self, name, *args, **kwargs):
kwargs['id'] = name
super(Adapter, self).__init__(*args, **kwargs)
# self.__dict__['name'] = name
##
for sname, sattributes in sections.iteritems():
section = Adapter(sname, sattributes)
print section.id, section.width, section.height
for ename, eattributes in section.elements.iteritems():
element = Adapter(ename, eattributes)
print element.id