2013年11月06日

レイアウト

今夏はCGお休みでした。
import maya.cmds as cmds

cmds.window(title="Long Name", widthHeight=(200, 150) )
scrollLayout = cmds.scrollLayout(
horizontalScrollBarThickness=16,
verticalScrollBarThickness=16)
form = cmds.formLayout()
tabs = cmds.tabLayout(innerMarginWidth=5, innerMarginHeight=5)
cmds.formLayout( form, edit=True, attachForm=((tabs, 'top', 0), (tabs, 'left', 0), (tabs, 'bottom', 0), (tabs, 'right', 0)) )

child1 = cmds.rowColumnLayout(numberOfColumns=3)
cmds.button()
cmds.button()
cmds.button()
cmds.setParent( '..' )

child2 = cmds.columnLayout()
cmds.text( label='controls here.' )
cmds.rowColumnLayout(numberOfColumns=3)
cmds.button()
cmds.button()
cmds.button()
cmds.setParent( '..' )
cmds.rowColumnLayout(numberOfColumns=3)
cmds.button()
cmds.button()
cmds.button()
cmds.setParent( '..' )
cmds.setParent( '..' )

objName = cmds.sphere()
child3 = cmds.columnLayout()
cmds.text( label='controls here.' )
cmds.rowColumnLayout(numberOfColumns=3)
cmds.button()
cmds.button()
cmds.button()
cmds.setParent( '..' )
cmds.rowColumnLayout( numberOfRows=3, rowHeight=[(1, 30), (2, 30)] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.tx' % objName[0] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.ty' % objName[0] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.tz' % objName[0] )
cmds.setParent( '..' )
cmds.setParent( '..' )

child4 = cmds.columnLayout()
cmds.text( label='controls here.' )
cmds.rowColumnLayout(numberOfColumns=4)
cmds.button()
cmds.button()
cmds.button()
cmds.button()
cmds.setParent( '..' )
cmds.text( label='controls here.' )
cmds.rowColumnLayout( numberOfRows=3, rowHeight=[(1, 30), (2, 30)] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.sx' % objName[0] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.sy' % objName[0] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.sz' % objName[0] )
cmds.setParent( '..' )
cmds.setParent( '..' )

objName = cmds.polyCube()
child5 = cmds.columnLayout()
cmds.text( label='controls here.' )
cmds.rowColumnLayout(numberOfColumns=5)
cmds.button()
cmds.button()
cmds.button()
cmds.button()
cmds.button()
cmds.setParent( '..' )
cmds.text( label='controls here.' )
cmds.rowColumnLayout( numberOfRows=6, rowHeight=[(1, 30), (2, 30)] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.tx' % objName[0] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.ty' % objName[0] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.tz' % objName[0] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.sx' % objName[0] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.sy' % objName[0] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.sz' % objName[0] )
cmds.setParent( '..' )
cmds.setParent( '..' )

objName = cmds.torus()
child6 = cmds.columnLayout()
cmds.text( label='controls here.' )
cmds.rowColumnLayout(numberOfColumns=3)
cmds.button()
cmds.button()
cmds.button()
cmds.setParent( '..' )
cmds.text( label='controls here.' )
cmds.rowColumnLayout( numberOfRows=11, rowHeight=[(1, 30), (2, 30)] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.tx' % objName[0] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.ty' % objName[0] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.tz' % objName[0] )
cmds.text( label='controls here.' )
cmds.rowColumnLayout(numberOfColumns=3)
cmds.button()
cmds.button()
cmds.button()
cmds.setParent( '..' )
cmds.text( label='controls here.' )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.sx' % objName[0] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.sy' % objName[0] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.sz' % objName[0] )
cmds.setParent( '..' )
cmds.setParent( '..' )

child7 = cmds.columnLayout( columnAttach=('both', 5), rowSpacing=10, columnWidth=400 )
cmds.menuBarLayout()
cmds.menu( label='Edit' )
cmds.menuItem( label='Cut' )
cmds.menuItem( label='Copy' )
cmds.menuItem( label='Paste' )

cmds.menu( label='View' )
cmds.menuItem( label='Fonts...' )
cmds.menuItem( label='Colors...' )

cmds.columnLayout()
cmds.text( label='Add some controls here.' )
cmds.setParent( '..' )
cmds.setParent( '..' )
cmds.setParent( '..' )

child8 = cmds.columnLayout( columnAttach=('both', 5), rowSpacing=10, columnWidth=400 )
cmds.menuBarLayout()
cmds.menu( label='Edit' )
cmds.menuItem( label='Cut' )
cmds.menuItem( label='Copy' )
cmds.menuItem( label='Paste' )

cmds.menu( label='View' )
cmds.menuItem( label='Fonts...' )
cmds.menuItem( label='Colors...' )

cmds.rowColumnLayout( numberOfRows=5, rowHeight=[(1, 30), (2, 30)] )
cmds.text( label='Add some controls here.' )
cmds.text( label='controls here.' )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.tx' % objName[0] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.ty' % objName[0] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.tz' % objName[0] )
cmds.setParent( '..' )
cmds.setParent( '..' )
cmds.setParent( '..' )

child9 = cmds.gridLayout( numberOfColumns=5, cellWidthHeight=(30, 30) )
cmds.button(1)
cmds.button(22)
cmds.button(33)
cmds.button(44)
cmds.button(55)
cmds.button(600)
cmds.button(700)
cmds.button(00)
cmds.button(001)
cmds.button(002)
cmds.button(003)
cmds.button(004)
cmds.button(005)
cmds.button(006)
cmds.button(007)
cmds.setParent( '..' )

child10 = cmds.columnLayout( columnAttach=('both', 5), rowSpacing=10, columnWidth=400 )
cmds.menuBarLayout()
cmds.menu( label='Edit' )
cmds.menuItem( label='Cut' )
cmds.menuItem( label='Copy' )
cmds.menuItem( label='Paste' )

cmds.menu( label='View' )
cmds.menuItem( label='Fonts...' )
cmds.menuItem( label='Colors...' )

cmds.gridLayout( numberOfColumns=5, cellWidthHeight=(30, 30) )
cmds.button(1)
cmds.button(22)
cmds.button(33)
cmds.button(44)
cmds.button(55)
cmds.button(600)
cmds.button(700)
cmds.button(00)
cmds.button(001)
cmds.button(002)
cmds.button(003)
cmds.button(004)
cmds.button(005)
cmds.button(006)
cmds.button(007)
cmds.setParent( '..' )
cmds.setParent( '..' )
cmds.setParent( '..' )

child11 = cmds.rowColumnLayout( numberOfRows=6, rowHeight=[(1, 30), (2, 30)] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.tx' % objName[0] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.ty' % objName[0] )
cmds.attrFieldSliderGrp( min=-10.0, max=10.0, at='%s.tz' % objName[0] )
cmds.button( label='Left', align='left' )
cmds.button( label='Center', align='center' )
cmds.button( label='Right', align='right' )
cmds.setParent( '..' )

cmds.tabLayout( tabs, edit=True, tabLabel=((child1, 'One'), (child2, 'Two'), (child3, '3'), (child4, '4'), \
(child5, '5'), (child6, '6'), (child7, '7'), (child8, '8'), (child9, '9'), (child10, '10'), (child11, '11')) )

cmds.showWindow()

value = cmds.scrollLayout(scrollLayout, query=True, scrollAreaValue=True)
top = value[0]
left = value[1]
posted by matsus at 21:01| python