python类setParent()的实例源码

ml_colorControl.py 文件源码 项目:ml_tools 作者: morganloomis 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def buildMainLayout(self):
        '''Build the main part of the ui
        '''

        #tabs = mc.tabLayout()

        #tab1 = mc.columnLayout(adj=True)
        #self.swatch_selected = self.colorControlLayout()
        #mc.button(label='Color Selected', command=self.colorSelected)
        #mc.setParent('..')

        #tab2 = mc.columnLayout(adj=True)
        self.swatch_range1 = self.colorControlLayout(label='First Selected')
        self.swatch_range2 = self.colorControlLayout(label='Last Selected')
        mc.separator(horizontal=True, height=10)
        mc.button(label='Color Selected Nodes', command=self.colorSelectedRange)
        #mc.setParent('..')

        #tab3 = mc.columnLayout(adj=True)
        #self.positionWidgets = {}
        #for xyz in 'XYZ':
            #for m in ['Min','Max']:        
                #self.positionWidgets[m+xyz] = self.colorControlLayout(label='{} {}'.format(m,xyz))

        mc.setParent('..')

        #mc.tabLayout( tabs, edit=True, tabLabel=((tab1, 'Color Control'), (tab2, 'Color Range')) )
chain_maker.py 文件源码 项目:ChainMaker 作者: XJZeng 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def __init__(self):
        window = cmds.window( title="Chain Maker", iconName='ChnMk', widthHeight=(300, 100) )
        cmds.columnLayout( adjustableColumn=True )
        cmds.separator( style='single' )
        self.curve_sel_name = cmds.textFieldGrp( label = 'Curve Selection' )
        cmds.separator( style='single' ) 
        cmds.button( label='Run', command=partial(self.run_command, 1) )
        cmds.separator( style='single' )     
        cmds.button( label='Exit', command=('cmds.deleteUI(\"' + window + '\", window=True)') )
        cmds.setParent( '..' )
        cmds.showWindow( window )
menu.py 文件源码 项目:config 作者: mindbender-studio 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def install():
    from . import interactive, tools

    def deferred():
        # Append to Avalon's menu
        cmds.menuItem(divider=True)

        # Modeling sub-menu
        cmds.menuItem("Modeling",
                      label="Modeling",
                      tearOff=True,
                      subMenu=True,
                      parent=self._menu)

        cmds.menuItem("Combine", command=interactive.combine)

        # Rigging sub-menu
        cmds.menuItem("Rigging",
                      label="Rigging",
                      tearOff=True,
                      subMenu=True,
                      parent=self._menu)

        cmds.menuItem("Auto Connect", command=interactive.auto_connect)
        cmds.menuItem("Clone (Local)", command=interactive.clone_localspace)
        cmds.menuItem("Clone (World)", command=interactive.clone_worldspace)
        cmds.menuItem("Clone (Special)", command=interactive.clone_special)
        cmds.menuItem("Create Follicle", command=interactive.follicle)

        # Animation sub-menu
        cmds.menuItem("Animation",
                      label="Animation",
                      tearOff=True,
                      subMenu=True,
                      parent=self._menu)

        cmds.menuItem("Set Defaults", command=interactive.set_defaults)

        # Rendering sub-menu
        cmds.menuItem("Rendering",
                      label="Rendering",
                      tearOff=True,
                      subMenu=True,
                      parent=self._menu)

        cmds.menuItem("Edit Render Globals",
                      command=tools.render_globals_editor)

        cmds.setParent("..", menu=True)

        cmds.menuItem(divider=True)

        cmds.menuItem("Auto Connect", command=interactive.auto_connect_assets)

    # Allow time for uninstallation to finish.
    QtCore.QTimer.singleShot(200, deferred)
orientjoints.py 文件源码 项目:cmt 作者: chadmv 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self):
        name = 'cmt_orientjoints'
        if cmds.window(name, exists=True):
            cmds.deleteUI(name, window=True)
        if cmds.windowPref(name, exists=True):
            cmds.windowPref(name, remove=True)
        self.window = cmds.window(name, title='CMT Orient Joints', widthHeight=(358, 330))
        cmds.columnLayout(adjustableColumn=True)
        margin_width = 4
        cmds.frameLayout(bv=False, label='Quick Actions', collapsable=True, mw=margin_width)
        cmds.gridLayout(numberOfColumns=2, cellWidthHeight=(175, 65))
        cmds.button(label='Make Planar Orientation', command=self.make_planar)
        cmds.button(label='Project to Planar Position', command=partial(make_position_planar))
        cmds.button(label='Align Up With Child', command=self.align_with_child)
        cmds.button(label='Zero Orient', command=self.zero_orient)
        cmds.button(label='Orient to World', command=self.orient_to_world)
        cmds.rowColumnLayout(numberOfColumns=4)

        height = 20
        label_width = 60
        icon_left = 'nudgeLeft.png'
        icon_right = 'nudgeRight.png'
        cmds.text(label='Offset X', align='right', width=label_width)
        cmds.iconTextButton(style='iconOnly', image1=icon_left, label='spotlight', h=height, w=height, c=partial(self.offset_orient_x, direction=-1))
        self.offset_x = cmds.floatField(value=90.0)
        cmds.iconTextButton(style='iconOnly', image1=icon_right, label='spotlight', h=height, w=height, c=partial(self.offset_orient_x, direction=1))
        cmds.text(label='Offset Y', align='right', width=label_width)
        cmds.iconTextButton(style='iconOnly', image1=icon_left, label='spotlight', h=height, w=height, c=partial(self.offset_orient_y, direction=-1))
        self.offset_y = cmds.floatField(value=90.0)
        cmds.iconTextButton(style='iconOnly', image1=icon_right, label='spotlight', h=height, w=height, c=partial(self.offset_orient_y, direction=1))
        cmds.text(label='Offset Z', align='right', width=label_width)
        cmds.iconTextButton(style='iconOnly', image1=icon_left, label='spotlight', h=height, w=height, c=partial(self.offset_orient_z, direction=-1))
        self.offset_z = cmds.floatField(value=90.0)
        cmds.iconTextButton(style='iconOnly', image1=icon_right, label='spotlight', h=height, w=height, c=partial(self.offset_orient_z, direction=1))

        cmds.setParent('..')
        cmds.setParent('..')
        cmds.setParent('..')
        cmds.frameLayout(bv=False, label='Manual Orient', collapsable=True, mw=margin_width)
        cmds.columnLayout(adj=True)
        cmds.rowLayout(numberOfColumns=2, cw2=(150, 150))
        self.reorient_children = cmds.checkBox(label='Reorient children', value=True, align='left')
        self.reset_orientation = cmds.checkBox(label='Reset orientation', value=True, align='left')
        cmds.setParent('..')
        cmds.gridLayout(numberOfColumns=2, cellWidthHeight=(175, 65))
        cmds.button(label='Template Joints', command=partial(self.template_joints))
        cmds.button(label='Rebuild Joints', command=partial(rebuild_joints))
        cmds.setParent('..')
        cmds.setParent('..')
        cmds.setParent('..')
        cmds.showWindow(self.window)
utils.py 文件源码 项目:pyshell 作者: oglops 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def add_menu(location='Window->General Editors', label='xxx', command='print "xxx"'):
    '''
    Add menu to specified location in main menu.

    Args:
        location: Window->General Editors.
        label: the label on the menu.
        command: the command
    '''
    # gMainWindowMenu='mainWindowMenu'
    import maya.cmds as mc
    menu_path = location.split('->')

    def get_menu_item(label, parent_menu=None):
        'returns menu item with label in parent_menu'
        menu_item = None

        # if it is top level menu
        for m in mc.lsUI(type='menu'):
            if mc.objectTypeUI(m) != 'commandMenuItem' and mc.menu(m, q=1, l=1) == label:
                menu_item = m

                if parent_menu:
                    if not menu_item in mc.menu(parent_menu, q=1, ia=1) or []:
                        continue
                else:
                    break

        pmc = mc.menu(menu_item, q=1, pmc=1)
        if pmc:
            mm.eval(pmc)

        return menu_item

    parent_menu = None
    for m in menu_path:
        menu_item = get_menu_item(m, parent_menu)
        parent_menu = menu_item

    print parent_menu

    # delete existing menuItem
    if mc.menu(parent_menu, q=1, ia=1):
        for m in mc.menu(parent_menu, q=1, ia=1):
            if mc.menuItem(m, q=1, l=1) == label:
                mc.deleteUI(m)
                break

    mc.setParent(menu_item, m=1)
    mc.menuItem(l=label, c=command)
burnin.py 文件源码 项目:mayakit 作者: danbradham 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def text_array_builder(self, attrName):
        frame = 'text_array_frame'

        if pm.columnLayout(frame, exists=True):
            pm.deleteUI(frame)

        pm.columnLayout(frame)
        pm.rowLayout(numberOfColumns=2)

        text_array_length = pm.getAttr(attrName, s=True)
        next_attr = '{}[{}]'.format(attrName, text_array_length)
        add_command = partial(self.add_text_multiInstance, next_attr)
        pm.button(label='New Item', command=add_command)

        last_attr = '{}[{}]'.format(attrName, text_array_length - 1)
        remove_command = partial(self.rem_text_multiInstance, last_attr)
        pm.button(label='Remove Last Item', command=remove_command)

        pm.setParent('..')

        self.textfields = []
        for i in xrange(text_array_length):
            index_attr = '{}[{}]'.format(attrName, i)
            textString_attr = index_attr + '.textString'
            textAlign_attr = index_attr + '.textAlign'
            textOffset_attr = index_attr + '.textOffset'
            textScale_attr = index_attr + '.textScale'
            textColor_attr = index_attr + '.textColor'
            textAlpha_attr = index_attr + '.textAlpha'
            textFamily_attr = index_attr + '.textFamily'
            textWeight_attr = index_attr + '.textWeight'
            textStretch_attr = index_attr + '.textStretch'

            pm.frameLayout(label=index_attr, collapse=False)
            pm.columnLayout(adj=True)

            text_field = pm.scrollField()
            self.textfields.append(text_field)
            text_field_cmd = partial(self.set_string_attr, text_field, textString_attr)
            text_field.changeCommand(text_field_cmd)
            text_field.keyPressCommand(text_field_cmd)
            text_field.setText(pm.getAttr(textString_attr))
            text_field.setEditable(True)

            pm.attrEnumOptionMenuGrp(
                attribute=textAlign_attr, label='textAlign')
            pm.attrFieldGrp(attribute=textOffset_attr, label='textOffset')
            pm.attrControlGrp(attribute=textScale_attr, label='textScale')
            pm.attrControlGrp(attribute=textColor_attr, label='textColor')
            pm.attrControlGrp(attribute=textAlpha_attr, label='textAlpha')
            pm.attrEnumOptionMenuGrp(
                attribute=textFamily_attr, label='textFamily')
            pm.attrEnumOptionMenuGrp(
                attribute=textWeight_attr, label='textWeight')
            pm.attrEnumOptionMenuGrp(
                attribute=textStretch_attr, label='textStretch')

            pm.setParent('..')
            pm.setParent('..')
zbw_window.py 文件源码 项目:zTools 作者: zethwillie 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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)
zbw_softDeformer.py 文件源码 项目:zTools 作者: zethwillie 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def softDeformerUI():
    """UI for the whole thing"""
# TODO - add some kind of help text to each tab
    if cmds.window("softModWin", exists=True):
        cmds.deleteUI("softModWin")
    widgets["window"] = cmds.window("softModWin", t="zbw_softDeformer", w=300, h=130)
    widgets["tabLO"] = cmds.tabLayout()
    widgets["smCLO"] = cmds.columnLayout("SoftMod", w=300)

    cmds.separator(h=10)
    widgets["smdTFG"] = cmds.textFieldGrp(l="Deformer Name", w=300, cw=[(1, 100), (2, 190)],
                                          cal=[(1, "left"), (2, "left")], tx="softMod_DEF")
    widgets["checkCBG"] = cmds.checkBoxGrp(l="AutoCheck if there are deformers?", v1=1, cw=[(1, 200)],
                                           cal=[(1, "left"), (2, "left")])
    widgets["frontCBG"] = cmds.checkBoxGrp(l="Auto move to front of chain", v1=1, cw=[(1, 200)],
                                           cal=[(1, "left"), (2, "left")])
    widgets["scaleFFG"] = cmds.floatFieldGrp(l="Control Scale", v1=1, pre=2, cw=[(1, 150), (2, 50)],
                                             cal=[(1, "left"), (2, "left")])
    widgets["autoscaleCBG"] = cmds.checkBoxGrp(l="autoscale control?", v1=1, cw=[(1, 200)],
                                           cal=[(1, "left"), (2, "left")])
    widgets["bpFrameIFG"] = cmds.intFieldGrp(l="BindPose/origin Frame", cw=[(1, 150), (2, 50)],
                                             cal=[(1, "left"), (2, "left")])
    widgets["mainCtrlTFBG"] = cmds.textFieldButtonGrp(l="Parent Object:", cw=[(1, 75), (2, 175), (3, 75)], cal=[(1,
                            "left"), (2, "left"), (3, "left")], bl="<<<", bc=partial(set_parent_object, "mainCtrlTFBG"))
    cmds.separator(h=10, style="single")
    widgets["smbutton"] = cmds.button(l="Create Deformer", w=300, h=40, bgc=(.6, .8, .6),
                                    c=partial(create_soft_mod_deformer, False))
    cmds.separator(h=5)
    widgets["wavebutton"] = cmds.button(l="Soft Wave (use falloff to scale wave)", w=300, h=30, bgc=(.8, .8, .6),
                                    c=partial(create_soft_mod_deformer, True))

    # third tab to do softselect to joint
    cmds.setParent(widgets["tabLO"])
    widgets["jointCLO"] = cmds.columnLayout("softJoint", w=300)
    widgets["jntNameTFG"] = cmds.textFieldGrp(l="Joint Name", w=300, cw=[(1, 100), (2, 190)],
                                          cal=[(1, "left"), (2, "left")], tx="softSelect_JNT")
    widgets["jntCPOMCBG"] = cmds.checkBoxGrp(l="Joint to closest point on mesh?", v1=1, cw=[(1, 200)],
                                            cal=[(1, "left"), (2, "left")])
    widgets["jntRotCBG"] = cmds.checkBoxGrp(l="Joint orient to surface?", v1=1, cw=[(1, 200)],
                                            cal=[(1, "left"), (2, "left")])
    widgets["jntAutoCBG"] = cmds.checkBoxGrp(l="Create initial jnt if not bound?", v1=1, cw=[(1, 200)],
                                            cal=[(1, "left"), (2, "left")])
    cmds.separator(h=10)
    widgets["jntbutton"] = cmds.button(l="Create Joint", w=300, h=40, bgc=(.6, .8, .6), c=soft_selection_to_joint)



    cmds.window(widgets["window"], e=True, w=5, h=5, rtf=True)
    cmds.showWindow(widgets["window"])

# --------------------------
# softMod deformer
# --------------------------
# TODO - Add 'wave' to name . . .
zbw_messageMapper.py 文件源码 项目:zTools 作者: zethwillie 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def zbw_mmUI():
    """the UI for the script"""

    if (cmds.window('`UI', exists=True)):
        cmds.deleteUI('zbw_messageMapperUI', window=True)
        cmds.windowPref('zbw_messageMapperUI', remove=True)
    window=cmds.window('zbw_messageMapperUI', widthHeight=(600,400), title='zbw_messageMapper')

    cmds.tabLayout(h=400)
    cmds.columnLayout("mmAddNewConnections", h=400)
    #2nd small column for the persistant UI
    cmds.columnLayout(w=400, h=100)
    cmds.textFieldButtonGrp('zbw_tfbg_baseObj', cal=(1, "left"), cw3=(75, 200, 75), label="base object", w=400, bl="choose object", bc=partial(zbw_mmAddBase, "zbw_tfbg_baseObj", "clear"))

    #button to create new message/obj field groups
    cmds.separator(h=20, st="single")
    cmds.button(w=150, l="add new message attr/obj", c=zbw_mmAddMObjs)
    cmds.separator(h=20, st="single")

    cmds.setParent(u=True)
    cmds.rowColumnLayout("mmRCLayout", nc=2, co=(2, "left", 30))

    #back up to the 2nd columnLayout
    cmds.setParent(u=True)

    cmds.separator(h=20, st="single")
    #create button to delete last pair of text fields
    cmds.button("deleteLastButton", w=150, bgc=(.5,0,0), l="delete last attr/obj pair", c=zbw_mmDeleteLast)
    cmds.separator(h=20, st="double")

    #button to do connect all the attr/messages
    cmds.button("createMessageButton", w=150, bgc=(0,.5,0), l="create messages", c=zbw_mmConnectM)

    #back up to the main column
    cmds.setParent(u=True)
    #back up to the tab
    cmds.setParent(u=True)
    #new tab
    cmds.columnLayout("existingMessages", w=600, h=400)

    #Here we add stuff to the second tab
    cmds.textFieldButtonGrp("mmListMessages", cal=(1, "left"), cw3=(75,200,75), label="baseObject", w=400, bl="choose object", bc=partial(zbw_mmAddBase,"mmListMessages", "noClear"))
    cmds.separator(h=20, st="double")
    #button to create list of message attrs
    cmds.button(w=200, l="list all message attr for base", bgc = (0,.5,0), c=partial(zbw_mmListCurrentMessages, "mmListMessages"))
    cmds.separator(h=20, st="double")
    cmds.text("rt-click on the attr or object to change the connection")
    cmds.separator(h=20, st="double")

    cmds.rowColumnLayout("mmRCTextLayout", w=600, nc=3, cw=[(1, 200),(2,290),(3,100)])
    cmds.text("ATTR")
    cmds.text("OBJECT")
    cmds.text("DELETE")

    cmds.showWindow(window)
zbw_spaceMatch_overComplex.py 文件源码 项目:zTools 作者: zethwillie 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def spaceMatchUI():
    if (cmds.window("spaceMatchWin", exists=True)):
        cmds.deleteUI("spaceMatchWin", window=True)

    widgets["window"] = cmds.window("spaceMatchWin", title="Space Matcher", w=250, h=300)
    widgets["mainLO"] = cmds.columnLayout()
    widgets["tabLO"] = cmds.tabLayout()
    widgets["getObjCLO"] = cmds.columnLayout()
    widgets["instruct"] = cmds.text("get obj, then attr, then space then do it")
    cmds.separator(h=10)

    #----------fill with selection automatically?
    widgets["objTFG"] = cmds.textFieldGrp(l="select obj", cw=([1,50],[2,150],[3,50]), cal=([1,"left"], [2,"left"],[3,"left"]), cc=clearList)
    widgets["matchObjButton"] = cmds.button(l="select object", c=partial(getObj, widgets["objTFG"]))
    cmds.separator(h=10)
    #-----------maybe here have it catch the selected obj by default
    #-----------and/or have a field for the attribute (default to "follow")
    widgets["getAttrButton"] = cmds.button(w=250, al="center", h=20, l="select enum space attr from obj", bgc= (.5, .5, 0), c=getAttr)
    #-----------when the attr is selected list the attrs automagically,
    widgets["spacesTSL"] = cmds.textScrollList(w=250, h=200, nr=8, ams=False, bgc=(.2, .2, .2))
    widgets["matchButton"] = cmds.button(w=250, al="center", h=40, bgc= (0,.5,0), l="space switch/match", c= doSpaceMatch)

    #tab for creation/setup of matching
    cmds.setParent(widgets["tabLO"])
    #----------in this tab, create frames. One (closable) to create constraint and fill items, check boxes for orient, position (with user selecting objects), one frame (maybe already filled out) (always open) for setting up attrs (message, strings)
    widgets["setupCLO"] = cmds.columnLayout()
    #frame layout for creating the constraints
    widgets["createFrameLO"] = cmds.frameLayout(l="create Constrants", collapsable=True, w=250)
    cmds.text("have em select for constraint")
    widgets["posRotCBG"] = cmds.checkBoxGrp(ncb=2, l1="translation", v1=True, l2="rotation", v2=True)
    #----------this button should just create the constraints on the objects in question, but then fill in what parts of the lower half it can
    widgets["createSetupButton"] = cmds.button(l="create constraints")

    cmds.setParent(widgets["setupCLO"])

    #frameLayout for setting up the attrs
    widgets["setupFrameLO"] = cmds.frameLayout(l="setup matching", collapsable=False, w=250, h=250)
    widgets["setupObjTFG"] = cmds.textFieldGrp(l="select ctrl obj", cw=([1,100],[2,150]), cal=([1,"left"], [2,"left"]))
    widgets["setupObjButton"] = cmds.button(l="get ctrl object", h=40, c= partial(getObj, widgets["setupObjTFG"]))

    widgets["setupConstrTFG"] = cmds.textFieldGrp(l="constraint", cw=([1,100],[2,150]), cal=([1,"left"], [2,"left"]))
    widgets["setupConstrButton"] = cmds.button(l="get constraint", h=40, c= partial(getObj, widgets["setupConstrTFG"]))

    #create list of attrs on constraint
    #attr = cmds.listAttr(sel,ud=True )
    #create list of spaces on obj attr

    cmds.tabLayout(widgets["tabLO"], e=True, tabLabel = ((widgets["getObjCLO"], "change spaces"),(widgets["setupCLO"], "setup matching")))

    cmds.showWindow(widgets["window"])
    cmds.window(widgets["window"], e=True, w=250, h=300)
pipeline.py 文件源码 项目:core 作者: getavalon 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _install_menu():
    from ..tools import (
        creator,
        loader,
        publish,
        cbloader,
        cbsceneinventory
    )

    from . import interactive

    _uninstall_menu()

    def deferred():
        cmds.menu(self._menu,
                  label=api.Session["AVALON_LABEL"],
                  tearOff=True,
                  parent="MayaWindow")

        cmds.menuItem("Create...",
                      command=lambda *args: creator.show(parent=self._parent))

        if api.Session.get("AVALON_EARLY_ADOPTER"):
            cmds.menuItem("Load...",
                          command=lambda *args:
                          cbloader.show(parent=self._parent,
                                        use_context=True))
        else:
            cmds.menuItem("Load...",
                          command=lambda *args:
                          loader.show(parent=self._parent))

        cmds.menuItem("Publish...",
                      command=lambda *args: publish.show(parent=self._parent),
                      image=publish.ICON)

        cmds.menuItem("Manage...",
                      command=lambda *args: cbsceneinventory.show(
                          parent=self._parent))

        cmds.menuItem(divider=True)

        cmds.menuItem("System",
                      label="System",
                      tearOff=True,
                      subMenu=True,
                      parent=self._menu)

        cmds.menuItem("Reload Pipeline", command=reload_pipeline)

        cmds.setParent("..", menu=True)

        cmds.menuItem("Reset Frame Range",
                      command=interactive.reset_frame_range)
        cmds.menuItem("Reset Resolution",
                      command=interactive.reset_resolution)

    # Allow time for uninstallation to finish.
    QtCore.QTimer.singleShot(100, deferred)
customOutliner.py 文件源码 项目:MSide 作者: jamesbdunlop 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __initUI(self):
        self.lyName = 'nOutlinerPaneLayout'
        self.outlinerPanelName = 'nOutlinerPanel'
        if not cmds.paneLayout(self.lyName, query = True, exists = True):
            ## Create the pane to parent the outliner to
            self.outlinerPanelLayout = cmds.paneLayout(self.lyName)
            cmds.setParent()
            self.outlinerPaneLayout_Ptr = mui.MQtUtil.findLayout(self.outlinerPanelLayout)

            ## Wrap the maya paneLayout as a QWidget
            self.outlinerPaneWidget = shiboken.wrapInstance(long(self.outlinerPaneLayout_Ptr), QWidget)
            self.outlinerPaneWidget.setObjectName('CustomOutlinerWidget')

            ## Check to see if the custom outliner panel already exists
            existPanels = [pnl for pnl in cmds.lsUI(panels = True) if self.outlinerPanelName in pnl]
            if existPanels:
                self.outlinerPanel = mui.MQtUtil.findLayout(self.outlinerPanelName)
                cmds.outlinerPanel(self.outlinerPanelName, edit = True, p = self.outlinerPanelLayout)
            else:
                self.outlinerPanel = cmds.outlinerPanel(self.outlinerPanelName,  l = self.outlinerPanelName, to = False, init = False, mbv = True, p = self.outlinerPanelLayout)

            ## Set up the defaults for the view
            self.fixEditor = cmds.outlinerEditor(self.outlinerPanelName, edit = True,
                                                 mainListConnection='worldList',
                                                 selectionConnection='modelList',
                                                 showShapes=False,
                                                 showAttributes=False,
                                                 showConnected=False,
                                                 showAnimCurvesOnly=False,
                                                 autoExpand=False,
                                                 showDagOnly=True,
                                                 ignoreDagHierarchy=False,
                                                 expandConnections=False,
                                                 showCompounds=True,
                                                 showNumericAttrsOnly=False,
                                                 highlightActive=True,
                                                 autoSelectNewObjects=False,
                                                 doNotSelectNewObjects=False,
                                                 transmitFilters=False,
                                                 showSetMembers=True,
                                                 setFilter='defaultSetFilter' )
        else:
            self.outlinerPaneLayout_Ptr = mui.MQtUtil.findLayout(self.lyName)
            self.outlinerPaneWidget = shiboken.wrapInstance(long(self.outlinerPaneLayout_Ptr), QWidget)
            self.outlinerPaneWidget.setObjectName('nOutlinerWidget')

        self.mainLayout.addWidget(self.outlinerPaneWidget, 1, 0)
        self.mainLayout.setContentsMargins(1,1,1,1)
        self.setContentsMargins(1,1,1,1)
ml_stopwatch.py 文件源码 项目:ml_tools 作者: morganloomis 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def ui(self):
        '''
        Launch a UI to display the marks that were recorded.
        '''

        with utl.MlUi('ml_stopwatchReport', 'Stopwatch Report', width=400, height=400, info='''This is the report from the stopwatch you just ran.
Adjust the start frame, and then press the frame buttons to jump to that frame.
The fields on the right can be used for notes.''', menu=False) as win:

            self.uiSlider = mc.intSliderGrp(field=True, label='Start Frame', value=self.startFrame, 
                minValue=((-0.5*self.frameMarks[-1])+self.startFrame), maxValue=(self.frameMarks[-1]/2)+self.startFrame, 
                fieldMinValue=-1000, fieldMaxValue=1000,
                changeCommand=self.uiUpdateStartFrame)

            self.frameRateField = mc.intFieldGrp(label='Frame Rate', value1=self.frameRate, enable1=False, extraLabel='fps', annotation='')

            mc.scrollLayout()
            mc.rowColumnLayout(numberOfColumns=3, columnWidth=[(1, 50), (2, 80), (3, 340)])
            mc.text('Frame')
            mc.text('Duration')
            mc.text('Notes')

            for i in range(3):
                mc.separator(style='single', height=15)

            self.uiButton = list()

            for i in range(len(self.frameMarks)):

                #frame button
                frame = self.frameMarks[i]+self.startFrame
                self.uiButton.append(mc.button(label=str(frame), annotation='Go to frame %i' % frame,command='import maya.cmds;maya.cmds.currentTime(%i,edit=True)' % frame))

                #duration text
                if i:
                    mc.text(label=str(self.frameMarks[i]-self.frameMarks[i-1]))
                else:
                    mc.text(label='Start')

                #notes field
                mc.textField()

            #add the stop
            mc.text(label='')
            mc.text(label='Stop')
            mc.setParent('..')
            mc.setParent('..')

            #next and prev buttons!
            mc.paneLayout(configuration='vertical2',separatorThickness=1)
            mc.button(label='<< Previous', command=self.previousFrame, annotation='Go to the previous frame in the list.')
            mc.button(label='Next >>', command=self.nextFrame, annotation='Go to the next frame in the list.')
ml_toolbox.py 文件源码 项目:ml_tools 作者: morganloomis 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def createMenuItem(self, parent=None, labelPrefix='', italicized=False):

        if self.isPython:
            menuName = 'mlMenu_'+self.module.__name__.replace('.','_')
        else:
            menuName = 'mlMenu_'+self.name

        #Create the label and print the tool
        label = labelPrefix+self.label

        #keyword args for the menu command
        kwargs = {'italicized':italicized}

        if self.hotkey:
            if len(self.hotkey.keys) == 1:
                kwargs['altModifier'] = self.hotkey.altModifier[0]
                kwargs['ctrlModifier'] = self.hotkey.ctrlModifier[0]

                if self.hotkey.keys[0].isupper():
                    kwargs['shiftModifier'] = True
                kwargs['keyEquivalent'] = self.hotkey.keys[0]

        if self.verbose:
            print self.depth*'\t'+label

        if mc.menuItem(menuName, exists=True):
            mc.deleteUI(menuName)

        insertAfter = None
        if self.isPython and hasattr(self.module,'insertAfter'):
            menuItemArray = mc.menu(parent, query=True, itemArray=True)
            if menuItemArray:
                menuItems = dict()
                for each in menuItemArray:
                    eachLabel = mc.menuItem(each, query=True, label=True)
                    menuItems[eachLabel] = each

                if self.module.insertAfter in menuItems:
                    kwargs['insertAfter'] = menuItems[self.module.insertAfter]

        mc.setParent(parent, menu=True)

        menuName = mc.menuItem(menuName, label=label, command=self.command, **kwargs)
ml_worldBake.py 文件源码 项目:ml_tools 作者: morganloomis 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def ui():
    '''
    User interface for world bake
    '''

    with utl.MlUi('ml_worldBake', 'World Bake', width=400, height=175, info='''Select objects, bake to locators in world, camera, or custom space.
When you're ready to bake back, select locators
and bake "from locators" to re-apply your animation.''') as win:

        mc.checkBoxGrp('ml_worldBake_bakeOnOnes_checkBox',label='Bake on Ones', 
                       annotation='Bake every frame. If deselected, the tool will preserve keytimes.')

        tabs = mc.tabLayout()
        tab1 = mc.columnLayout(adj=True)
        mc.radioButtonGrp('ml_worldBake_space_radioButton', label='Bake To Space', numberOfRadioButtons=3,
                          labelArray3=('World','Camera','Last Selected'), select=1,
                          annotation='The locators will be parented to world, the current camera, or the last selection.')
        mc.checkBoxGrp('ml_worldBake_constrain_checkBox',label='Maintain Constraints', 
                       annotation='Constrain source nodes to the created locators, after baking.')

        win.ButtonWithPopup(label='Bake Selection To Locators', command=toLocators, annotation='Bake selected object to locators specified space.',
            readUI_toArgs={'bakeOnOnes':'ml_worldBake_bakeOnOnes_checkBox',
                           'spaceInt':'ml_worldBake_space_radioButton', 
                           'constrainSource':'ml_worldBake_constrain_checkBox'}, 
            name=win.name)#this last arg is temp..
        mc.setParent('..')

        tab2 = mc.columnLayout(adj=True)
        win.ButtonWithPopup(label='Bake Selected Locators Back To Objects', command=fromLocators, annotation='Bake from selected locators back to their source objects.',
            readUI_toArgs={'bakeOnOnes':'ml_worldBake_bakeOnOnes_checkBox'}, name=win.name)#this last arg is temp..
        mc.setParent('..')

        tab3 = mc.columnLayout(adj=True)
        mc.checkBoxGrp('ml_worldBake_maintainOffset_checkBox',label='Maintain Offset', 
                       annotation='Maintain the offset between nodes, rather than snapping.')
        win.ButtonWithPopup(label='Bake Selected', command=utl.matchBake, annotation='Bake from the first selected object directly to the second.',
            readUI_toArgs={'bakeOnOnes':'ml_worldBake_bakeOnOnes_checkBox',
                           'maintainOffset':'ml_worldBake_maintainOffset_checkBox'}, name=win.name)#this last arg is temp..

        mc.tabLayout( tabs, edit=True, tabLabel=((tab1, 'Bake To Locators'), (tab2, 'Bake From Locators'), (tab3, 'Bake Selection')) )        
#        win.ButtonWithPopup(label='Bake Selected With Offset', command=matchBake, annotation='Bake from the first selected object directly to the second, maintaining offset.',
#            readUI_toArgs={'bakeOnOnes':'ml_worldBake_bakeOnOnes_checkBox'}, name=win.name)#this last arg is temp..


问题


面经


文章

微信
公众号

扫码关注公众号