Python maya.cmds 模块,formLayout() 实例源码

我们从Python开源项目中,提取了以下17个代码示例,用于说明如何使用maya.cmds.formLayout()

项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def getScriptsUI(*args):

    if cmds.window("thisWin", exists = True):
        cmds.deleteUI("thisWin")

    widgets["win"] = cmds.window("thisWin", w=300, h=200)
    widgets["mainFLO"] = cmds.formLayout()

    widgets["list"] = cmds.textScrollList(nr=10, w=300, dcc = executeCommand)

    cmds.formLayout(widgets["mainFLO"], e=1, af = [(widgets["list"], "left", 0), (widgets["list"], "top", 0), (widgets["list"], "bottom", 30), (widgets["list"], "right", 0)])

    widgets["button"] = cmds.button(l="Refresh List!", w=300, h= 30, bgc = (.8, .6, .3), c= getScripts)
    cmds.formLayout(widgets["mainFLO"], e=1, af = [(widgets["button"], "left", 0), (widgets["button"], "right", 0), (widgets["button"], "bottom", 0)])

    cmds.showWindow(widgets["win"])

#populate the list with the contents of the path
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def ui():
    '''
    User interface for ml_tangentWeight
    '''

    with utl.MlUi('ml_tangentWeight', 'Weight Keyframe Tangents', width=400, height=140, 
                  info='''Increase or decrease tangents length without affecting tangent angle.
Select keyframes and press buttons to weight their tangents.
If no keys are selected, the keys on the current frame will be affected.''') as win:

        form = mc.formLayout()
        b11 = win.buttonWithPopup(label='-', command=minus, annotation='Scale tangent down.')
        b12 = win.buttonWithPopup(label='+', command=plus, annotation='Scale tangent up.')
        b21 = win.buttonWithPopup(label='<', command=sharkFinLeft, annotation='Weight tangent toward the left.')
        b22 = win.buttonWithPopup(label='>', command=sharkFinRight, annotation='Weight tangent toward the right.')

        utl.formLayoutGrid(form, (
            (b11,b12),
            (b21,b22)
            ))
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
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)
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def finish(self):
        '''
        Finalize the UI
        '''

        mc.setParent(self.form)

        frame = mc.frameLayout(labelVisible=False)
        mc.helpLine()

        mc.formLayout( self.form, edit=True,
                       attachForm=((self.column, 'top', 0), (self.column, 'left', 0),
                                   (self.column, 'right', 0), (frame, 'left', 0),
                                   (frame, 'bottom', 0), (frame, 'right', 0)),
                       attachNone=((self.column, 'bottom'), (frame, 'top')) )

        mc.showWindow(self.name)
        mc.window(self.name, edit=True, width=self.width, height=self.height)
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def ui():
    '''
    User interface for ml_lockAndHideAttributes
    '''

    with utl.MlUi('ml_lockAndHideAttributes', 'Lock and Hide', width=400, height=140, info='''Select channels in the channel box to be locked or hidden.
then hit the appropriate button.''') as win:

        form = mc.formLayout()
        b11 = win.buttonWithPopup(label='Lock', command=lock, annotation='Lock selected attributes.')
        b12 = win.buttonWithPopup(label='Hide', command=hide, annotation='Hide selected attributes.')
        b13 = win.buttonWithPopup(label='Lock and Hide', command=lockAndHide, annotation='Lock and hide selected attributes.')
        b21 = win.buttonWithPopup(label='Unlock', command=unlock, annotation='Unlock selected attributes.')
        b22 = win.buttonWithPopup(label='Unhide', command=unhide, annotation='Unhide all core attributes.')
        b23 = win.buttonWithPopup(label='Unlock and Unhide', command=unlockAndUnhide, annotation='Unlock and unhide selected attributes.')

        utl.formLayoutGrid(form, (
            (b11,b21),
            (b12,b22),
            (b13,b23)
            ))
项目:cmt    作者:chadmv    | 项目源码 | 文件源码
def about():
    """Displays the CMT About dialog."""
    name = 'cmt_about'
    if cmds.window(name, exists=True):
        cmds.deleteUI(name, window=True)
    if cmds.windowPref(name, exists=True):
        cmds.windowPref(name, remove=True)
    window = cmds.window(name, title='About CMT', widthHeight=(600, 500), sizeable=False)
    form = cmds.formLayout(nd=100)
    text = cmds.scrollField(editable=False, wordWrap=True, text=cmt.__doc__.strip())
    button = cmds.button(label='Documentation', command='import cmt.menu; cmt.menu.documentation()')
    margin = 8
    cmds.formLayout(form, e=True,
                    attachForm=(
                        (text, 'top', margin),
                        (text, 'right', margin),
                        (text, 'left', margin),
                        (text, 'bottom', 40),
                        (button, 'right', margin),
                        (button, 'left', margin),
                        (button, 'bottom', margin),
                    ),
                    attachControl=(
                        (button, 'top', 2, text)
                    ))
    cmds.showWindow(window)
项目:surume    作者:tm8r    | 项目源码 | 文件源码
def show_ui(self):
        u"""Window???"""
        if cmds.window(self._WINDOW_NAME, exists=True):
            cmds.deleteUI(self._WINDOW_NAME)

        self.window = cmds.window(self._WINDOW_NAME,
                                  t=self._WINDOW_TITLE,
                                  width=340,
                                  maximizeButton=False, minimizeButton=False)

        form = cmds.formLayout()
        field_group = cmds.columnLayout(adj=True, cal="center", rs=self._MARGIN)
        cmds.text(u"""???????????????????????????????
????????????????????????????""", al="left")
        self.text_scroll = cmds.textScrollList(append=self.get_windows(), ams=False, dcc=self.check_execute)
        self.text_field = cmds.textFieldGrp(l=u"????", ad2=2, cl2=["left", "left"], cw=[1, 60])
        cmds.setParent("..")

        button_group = cmds.columnLayout(adj=True, cal="center")
        cmds.button(l="Check", c=self.check_execute)
        cmds.setParent("..")

        cmds.formLayout(form, e=True,
                        attachForm=[(field_group, "top", self._MARGIN),
                                    (field_group, "left", self._MARGIN),
                                    (field_group, "right", self._MARGIN),
                                    (button_group, "bottom", self._MARGIN),
                                    (button_group, "left", self._MARGIN),
                                    (button_group, "right", self._MARGIN)],
                        attachControl=[(button_group, "top", self._MARGIN, field_group)])
        cmds.setParent("..")

        cmds.showWindow(self.window)
项目:surume    作者:tm8r    | 项目源码 | 文件源码
def _create_ui(self):
        safe_delete_window(self._WINDOW_NAME)

        win = cmds.window(self._WINDOW_NAME)

        form = cmds.formLayout()
        field_group = cmds.columnLayout(adj=True, cal="center", rs=self._MARGIN)
        cmds.text(u"????????focalLength?????Unity?FOV?????????????", al="left")
        self.text_scroll = cmds.textScrollList(append=self._get_cameras(), ams=False, dcc=self._select)
        self.text_field = cmds.textFieldGrp(l=u"FOV", ad2=2, cl2=["left", "left"], cw=[1, 60])
        self.result_field = cmds.textFieldGrp(l=u"Result", ad2=2, cl2=["left", "left"], cw=[1, 60])
        cmds.setParent("..")

        button_group = cmds.columnLayout(adj=True, cal="center")
        cmds.button(l="Apply", c=self._apply)
        cmds.setParent("..")

        cmds.formLayout(form, e=True,
                        attachForm=[(field_group, "top", self._MARGIN),
                                    (field_group, "left", self._MARGIN),
                                    (field_group, "right", self._MARGIN),
                                    (button_group, "bottom", self._MARGIN),
                                    (button_group, "left", self._MARGIN),
                                    (button_group, "right", self._MARGIN)],
                        attachControl=[(button_group, "top", self._MARGIN, field_group)])
        cmds.setParent("..")

        cmds.showWindow(win)
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def transformBufferUI(*args):
    if cmds.window("tbWin", exists=True):
        cmds.deleteUI("tbWin")

    widgets["win"] = cmds.window("tbWin", t="zbw_tranformBuffer", s=False, w=200)
    widgets["mainCLO"] = cmds.columnLayout(w=200)

######## ------ checkbox to enable/disable these. . . .

    widgets["trnFFG"] = cmds.floatFieldGrp(l="Trns: ", nf=3, cw=[(1, 40), (2, 50), (3, 50), (4,50)], cal = [(1, "left"), (2, "left"), (3, "left"), (4,"left")])
    widgets["rotFFG"] = cmds.floatFieldGrp(l="Rot: ", nf=3, cw=[(1, 40), (2, 50), (3, 50), (4,50)], cal = [(1, "left"), (2, "left"), (3, "left"), (4,"left")])
    widgets["sclFFG"] = cmds.floatFieldGrp(l="Scl: ", nf=3, cw=[(1,40), (2, 50), (3, 50), (4,50)],cal = [(1, "left"), (2, "left"), (3, "left"), (4,"left")])
    cmds.separator(h=10)
    widgets["transCBG"] = cmds.checkBoxGrp(ncb=3, la3 = ("Trns", "Rot", "Scl"), va3=(1, 1, 1), cal=[(1, "left"), (2, "left"), (3, "left")], cw = [(1, 50), (2, 50), (3, 50)])
    cmds.separator(h=10)
    widgets["butFLO"] = cmds.formLayout(w=200, h=50)
    widgets["getBut"] = cmds.button(l="Catch\nValues", bgc = (.8, .5, .5), h=50, w=100, c=getValues)
    widgets["setBut"] = cmds.button(l="Set\nValues", bgc = (.5, .8,.5), h=50, w=100, c=setValues)

    cmds.formLayout(widgets["butFLO"], e=True, af = [
        (widgets["getBut"], "top", 0),
        (widgets["getBut"], "left", 0),
        (widgets["setBut"], "top", 0),
        (widgets["setBut"], "left", 100)
        ])
    cmds.window(widgets["win"], e=True, w=200, h=100)
    cmds.showWindow(widgets["win"])
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def deformerWeightUI(*args):
    if cmds.window("defWgtsWin", exists=True):
        cmds.deleteUI("defWgtsWin")
    w, h = 300, 200
    widgets["win"] = cmds.window("defWgtsWin", w=w, h=h, t="zbw_deformerWeights")
    widgets["mainFLO"] = cmds.formLayout(w=w, h=h)

    widgets["defTSL"] = cmds.textScrollList(w=w, h=100, allowMultiSelection=True)
    widgets["weightFFG"] = cmds.floatFieldGrp(w=w, l="Weight Mult (soft)selection value x this", v1=1.0, cw=[(1, 215), (2, 50)], cal=[(1, "left"), (2, "left")], cc=limitMinMax)
    widgets["objTFG"] = cmds.textFieldGrp(w=w, l="Deforming Object", cw=[(1, 100), (2, 200)], cal=[(1, "left"), (2, "left")], en=False)
    widgets["doBut"] = cmds.button(l="set selected weights (based on softSel)", w=w, h=40, bgc = (.5, .7, .5), c=partial(setWeights, "selection"))
    widgets["zeroBut"] = cmds.button(l="zero all weights on selected deformer", w=w, h=20, bgc = (.7, .7, .5), c=partial(setWeights,"zero"))
    widgets["resetBut"] = cmds.button(l="reset deformer list based on selection obj", w=w, h=20, bgc = (.7, .5, .5), c=populateList)

    cmds.formLayout(widgets["mainFLO"], e=True, af=[
        (widgets["defTSL"], "left", 0),
        (widgets["defTSL"], "top", 0),
        (widgets["objTFG"], "left", 0),
        (widgets["objTFG"], "top", 105),                
        (widgets["zeroBut"], "left", 0),
        (widgets["zeroBut"], "top", 135),     
        (widgets["weightFFG"], "left", 0),
        (widgets["weightFFG"], "top", 165),  
        (widgets["doBut"], "left", 0),
        (widgets["doBut"], "top", 195),
        (widgets["resetBut"], "left", 0),
        (widgets["resetBut"], "top", 245),
        ])

    cmds.window(widgets["win"], e=True, w=5, h=5, rtf=True)
    cmds.showWindow(widgets["win"])
    populateList()
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def layer_editor_reset():  # re-parent layer editor to default maya channelbox
    layout_pane = mel.eval("$tmpvar=$gChannelsLayersPane")
    layer_editor_form = mel.eval("$tmpvar=$gLayerEditorForm")

    if layer_editor_form:
        cmds.formLayout(layer_editor_form, e=1, parent=layout_pane)
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_make(box_ui, _menu="jtChannelBox_Menu_Modelling"):
    data = data_load()
    exists = 0
    if box_ui.box is not None:
        del box_ui.box
    else:
        key = currentset_get()
        _menu = _menu if not key else data[key]
    if box_ui.menu_layout is not None:
        exists = 1

    # find the key pertaining to this menu to set as current
    value = [key for key, value in data.iteritems() if value == _menu][0] if data else "None"
    currentset_set(value)
    # cbox.ChannelBox parameters : (layout to parent channel box to, name of file containing menus to use,
    # what to name the file created to store persistent states, True/False/1/0 whether to save states or not)
    box_ui.box = CBox.ChannelBox(box_ui.layout_cbox, _menu, "jtChannelBox_State_Custom", 1)
    cmds.formLayout(box_ui.layout_cbox, e=1,
                    attachForm=[(box_ui.box.layout, "left", 1), (box_ui.box.layout, "right", 1),
                                (box_ui.box.layout, "bottom", 3), (box_ui.box.layout, "top", 0)])

    if exists:
        cmds.formLayout(box_ui.layout_cbox, e=1,
                        attachForm=[(box_ui.menu_layout, "bottom", 10), (box_ui.menu_layout, "right", 0),
                                    (box_ui.menu_layout, "left", 0)],
                        attachControl=(box_ui.box.layout, "bottom", 10, box_ui.menu_layout))
项目:MSide    作者:jamesbdunlop    | 项目源码 | 文件源码
def parentMaya(self):
            cmds.paneLayout('ChannelsLayersPaneLayout', edit = True, parent = 'MainChannelsLayersLayout')
            for form in cmds.layout('MainChannelsLayersLayout', query = True, ca = True):
                if 'ChannelButtonForm' in form:
                    cmds.formLayout('MainChannelsLayersLayout', edit = True, af = [('ChannelButtonForm', 'top', 0)])
                else:
                    cmds.formLayout('MainChannelsLayersLayout', edit = True, af = [(form, 'top', 20), (form, 'left', 0), (form, 'bottom', 0), (form, 'right', 0)])
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def buildWindow(self):
        '''
        Initialize the UI
        '''

        if mc.window(self.name, exists=True):
            mc.deleteUI(self.name)

        mc.window(self.name, title='ml :: '+self.title, iconName=self.title, width=self.width, height=self.height, menuBar=self.menu)


        if self.menu:
            self.createMenu()

        self.form = mc.formLayout()
        self.column = mc.columnLayout(adj=True)


        mc.rowLayout( numberOfColumns=2, columnWidth2=(34, self.width-34), adjustableColumn=2, 
                      columnAlign2=('right','left'),
                      columnAttach=[(1, 'both', 0), (2, 'both', 8)] )

        #if we can find an icon, use that, otherwise do the text version
        if self.icon:
            mc.iconTextStaticLabel(style='iconOnly', image1=self.icon)
        else:
            mc.text(label=' _ _ |\n| | | |')

        if not self.menu:
            mc.popupMenu(button=1)
            mc.menuItem(label='Help', command=(_showHelpCommand(wikiURL+'#'+self.name)))

        mc.text(label=self.info)
        mc.setParent('..')
        mc.separator(height=8, style='single', horizontal=True)
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def createUI(self):
        """creates the UI """

        self.widgets = {}

        width = self.windowSize[0]
        height = self.windowSize[1]

        if (cmds.window("zbw_win", exists=True)):
            cmds.deleteUI("zbw_win")

        self.widgets["window"] = cmds.window("zbw_win", title=self.windowName, w=width, h=height, s=self.sizeable)

        #menus for future
        self.menus()

        cmds.setParent(self.widgets["window"])
        self.widgets['formLO'] = cmds.formLayout(nd=100, w=width)
        # self.widgets["topColumnLO"] = cmds.columnLayout(w=width)
        self.widgets["scrollLO"] = cmds.scrollLayout(vst=10)
        self.widgets["lowColumnLO"] = cmds.columnLayout(w=width)
        cmds.formLayout(self.widgets["formLO"], e=True, attachForm = [(self.widgets["scrollLO"], "top", 0), (self.widgets["scrollLO"], "left", 0), (self.widgets["scrollLO"], 'right', 0), (self.widgets["scrollLO"], 'bottom', 35)])

        self.commonUI()

        self.customUI()

        #get to buttons bit
        cmds.setParent(self.widgets["formLO"])

        butWidth = width/3 - 10

        #add buttons
        self.widgets["applyCloseButton"] = cmds.button(w=butWidth, h=30, l='Apply and Close', c=partial(self.action, 1))
        self.widgets["applyButton"] = cmds.button(w=butWidth, h= 30, l='Apply', c=partial(self.action, 0))
        self.widgets['closeButton'] = cmds.button(w=butWidth, h=30, l="close window", c=self.closeWindow)

        cmds.formLayout(self.widgets["formLO"], e=True, attachForm=[(self.widgets["applyCloseButton"], 'bottom', 5), (self.widgets["applyCloseButton"], 'left', 5)])
        cmds.formLayout(self.widgets["formLO"], e=True, attachForm=[(self.widgets["closeButton"], 'bottom', 5), (self.widgets["closeButton"], 'right', 5)])
        cmds.formLayout(self.widgets["formLO"], e=True, attachForm=[(self.widgets["applyButton"], 'bottom', 5)])
        cmds.formLayout(self.widgets["formLO"], e=True, attachControl=[(self.widgets["applyButton"], 'left', 5, self.widgets["applyCloseButton"]),(self.widgets["applyButton"], 'right', 5, self.widgets["closeButton"])])


        cmds.showWindow(self.widgets["window"])
        cmds.window(self.widgets["window"], e=True, w=width, h=height)
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def shapeScaleUI():
    """
    UI for the script
    """

    if (cmds.window("ssWin", exists=True)):
        cmds.deleteUI("ssWin", window=True)
        # cmds.winPref("shapeScaleWin", remove=True)

    widgets["win"] = cmds.window("ssWin", t="zbw_shapeScale", w=400, h=75, s=False)

    widgets["colLo"] = cmds.columnLayout("mainCLO", w=400, h=75)
    widgets["formLO"] = cmds.formLayout(nd=100, w=400)
    cmds.separator(h=10)
    widgets["slider"] = cmds.floatSliderGrp("slider", f=False, l="Scale", min=0.01, max=2, pre=3, v=1, adj=3,
                                            cal=([1, "left"], [2, "left"], [3, "left"]), cw=([1, 50], [2, 220]),
                                            cc=shapeScaleExecute)
    cmds.separator(h=10)
    widgets["scaleFFG"] = cmds.floatFieldGrp(v1=100, pre=1, l="Scale %", en1=True, w=110, cw=([1, 50], [2, 50]),
                                             cal=([1, "left"], [2, "left"]))
    widgets["scaleDoBut"] = cmds.button(l="Scale", w=160, h=25, bgc=(.2, .4, .2), c=manualScale)
    widgets["trackerFFG"] = cmds.floatFieldGrp(l="Change", w=100, v1=100, pre=1, en1=False, cw=([1, 45], [2, 50]),
                                               cal=([1, "left"], [2, "right"]), bgc=(.2, .2, .2))
    widgets["clearBut"] = cmds.button(l="RESET", w=45, bgc=(.2, .2, .2), c=resetScale)

    widgets["origBut"] = cmds.button(l="ORIG", w=45, bgc=(.2, .2, .2), c=origScale)

    # attach to form layout
    cmds.formLayout(widgets["formLO"], e=True,
                    attachForm=[(widgets["slider"], 'top', 5), (widgets["slider"], 'left', 5)])
    cmds.formLayout(widgets["formLO"], e=True,
                    attachForm=[(widgets["scaleFFG"], 'top', 34), (widgets["scaleFFG"], 'left', 5)])
    cmds.formLayout(widgets["formLO"], e=True,
                    attachForm=[(widgets["scaleDoBut"], 'top', 34), (widgets["scaleDoBut"], 'left', 120)])
    cmds.formLayout(widgets["formLO"], e=True,
                    attachForm=[(widgets["clearBut"], 'top', 34), (widgets["clearBut"], 'left', 344)])
    cmds.formLayout(widgets["formLO"], e=True,
                    attachForm=[(widgets["trackerFFG"], 'top', 5), (widgets["trackerFFG"], 'left', 290)])
    cmds.formLayout(widgets["formLO"], e=True,
                    attachForm=[(widgets["origBut"], 'top', 34), (widgets["origBut"], 'left', 290)])

    cmds.showWindow(widgets["win"])
    cmds.window(widgets["win"], e=True, w=400, h=75)
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_symbols(box, *args):
    # create buttons for each menu icon
    b_manip = cmds.symbolButton(p=box.symbol_layout)
    b_speed = cmds.symbolButton(p=box.symbol_layout)
    b_hyper = cmds.symbolButton(p=box.symbol_layout)
    # attach buttons to form layout
    cmds.formLayout(box.symbol_layout, e=1, attachForm=[
        (b_manip, "top", 0),
        (b_manip, "bottom", 1),
        (b_speed, "top", 0),
        (b_speed, "bottom", 1),
        (b_hyper, "top", 0),
        (b_hyper, "bottom", 1),
        (b_hyper, "right", 2),

    ],
                    attachNone=[
                        (b_manip, "left"),
                        (b_speed, "left"),
                        (b_hyper, "left")
                    ],
                    attachControl=[
                        (b_manip, "right", 2, b_speed),
                        (b_speed, "right", 2, b_hyper)

                    ])

    # add the commands for each button (stored in box.sym)
    cmds.symbolButton(b_manip, e=1, c=sysCmd.rpartial(box.sym["pressed"], box, "manipsState"))
    cmds.symbolButton(b_speed, e=1, c=sysCmd.rpartial(box.sym["pressed"], box, "speedState"))
    cmds.symbolButton(b_hyper, e=1, c=sysCmd.rpartial(box.sym["pressed"], box, "hyperbolic"))

    # store the buttons themselves for updating when changed via menu options instead of button presses
    box.symbols["manipsState"] = b_manip
    box.symbols["speedState"] = b_speed
    box.symbols["hyperbolic"] = b_hyper

    # call their update function on creation to set them to their current states (because data is serialized,
    # may not be default on creation)
    for key in box.symbols:
        box.sym["update"](box, key)


# -----------------------------------------------------------------------------------

# ----------------------------------------
# -- MODIFY BELOW THIS LINE AT OWN RISK --
#       You will break many things
# ----------------------------------------

# --------------------------------------------------------------------------------------
# CORE SYSTEM : This is setup very specifically to NOT require you to modify this part
#
# If you need changes here, feel free to email me at the address provided if you feel
# that they could benefit everyone
# --------------------------------------------------------------------------------------