ここでは FormLayout() と、
tabLayout() の使用方法を練習してみましょう。
formLayout() はレイアウトの中で最も自由がきくもので、
ウインドウの上下左右からの絶対位置や、
他の部品からの相対位置によって部品を配置することができます。
tabLayout() はタブを作成することができます。
この関数を実行すると、
それ以降の部品・レイアウトはタブグループになり、 1 つのタブになってゆきます。
まず、FormLayout() によってタブの部分と 閉じる ボタンを配置し、tabLayout() によって A・B ボタンのあるタブと C・D ボタンのあるタブを切替えることができるようにしてみましょう。
string $windowName = `window -title "layout5"`; string $form = `formLayout`; string $closeButton = `button -label "閉じる" -command ("deleteUI " + $windowName)`; formLayout -edit -attachForm $closeButton "top" 130 -attachForm $closeButton "left" 0 -attachForm $closeButton "bottom" 0 -attachForm $closeButton "right" 0 $form; string $tabs = `tabLayout -innerMarginWidth 10 -innerMarginHeight 10`; formLayout -edit -attachForm $tabs "top" 0 -attachForm $tabs "left" 0 -attachControl $tabs "bottom" 10 $closeButton -attachForm $tabs "right" 0 $form; string $tab1 = `columnLayout`; button -label "A"; button -label "B"; setParent ..; string $tab2 = `columnLayout`; button -label "C"; button -label "D"; setParent ..; tabLayout -edit -tabLabel $tab1 "タブ1" -tabLabel $tab2 "タブ2" $tabs; showWindow;
import pymel.core as pm with pm.window(title='layout5') as windowName: form = pm.formLayout() closeButton = pm.button(label=u'閉じる', command=pm.Callback(pm.deleteUI, windowName.name()) pm.formLayout(form, edit=True, attachForm=((closeButton, 'top', 130), (closeButton, 'left', 0), (closeButton, 'bottom', 0), (closeButton, 'right', 0))) with pm.tabLayout(innerMarginWidth=10, innerMarginHeight=10) as tabs: with pm.columnLayout() as tab1: pm.button(label='A') pm.button(label='B') pm.setParent('..') with pm.columnLayout() as tab2: pm.button(label='C') pm.button(label='D') pm.setParent('..') pm.formLayout(form, edit=True, attachForm=((tabs, 'top', 0), (tabs, 'left', 0), (tabs, 'right', 0)), attachControl=(tabs, 'bottom', 10, closeButton)) pm.tabLayout(tabs, edit=True, tabLabel=((tab1, u'タブ1'), (tab2, u'タブ2')))
import pymel.core as pm
with pm.window(title='layout5') as windowName:
form = pm.formLayout()
closeButton = pm.button(label=u'閉じる', command=pm.Callback(pm.deleteUI, windowName.name())
pm.formLayout(form, edit=True,\
attachForm=((closeButton, 'top', 130),\
(closeButton, 'left', 0),\
(closeButton, 'bottom', 0),\
(closeButton, 'right', 0)))
(closeButton, 'top', 130)
(closeButton, 'left', 0)
(closeButton, 'bottom', 0)
(closeButton, 'right', 0)
with pm.tabLayout(innerMarginWidth=10, innerMarginHeight=10) as tabs:
pm.formLayout(form, edit=True,\
attachForm=((tabs, 'top', 0),\
(tabs, 'left', 0),\
(tabs, 'right', 0)),\
attachControl=(tabs, 'bottom', 10, closeButton))
(tabs, 'top', 0)
(tabs, 'left', 0)
(tabs, 'right', 0)
(tabs, 'bottom', 10, closeButton)
with pm.columnLayout() as tab1:
pm.button(label='A')
pm.button(label='B')
with pm.columnLayout() as tab2:
pm.button(label='C')
pm.button(label='D')
pm.tabLayout(tabs, edit=True, tabLabel=((tab1, u'タブ1'), (tab2, u'タブ2')))