def formLayoutGrid(form, controls, offset=1):
'''
Controls should be a list of lists, and this will arrange them in a grid
'''
kwargs = {'edit':True, 'attachPosition':list()}
rowInc = 100/len(controls)
colInc = 100/len(controls[0])
position = {'left':0,'right':100,'top':0,'bottom':100}
for r,row in enumerate(controls):
position['top'] = r*rowInc
position['bottom'] = (r+1)*rowInc
for c,ctrl in enumerate(row):
position['left'] = c*colInc
position['right'] = (c+1)*colInc
for k in position.keys():
kwargs['attachPosition'].append((ctrl, k, offset, position[k]))
mc.formLayout(form, **kwargs)
评论列表
文章目录