Python maya.cmds.paneLayout() Examples

The following are 9 code examples of maya.cmds.paneLayout(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module maya.cmds , or try the search function .
Example #1
Source File: ml_breakdown.py    From ml_tools with MIT License 7 votes vote down vote up
def quickBreakDownUI():
    winName = 'ml_quickBreakdownWin'
    if mc.window(winName, exists=True):
        mc.deleteUI(winName)

    mc.window(winName, title='ml :: QBD', iconName='Quick Breakdown', width=100, height=500)

    mc.columnLayout(adj=True)

    mc.paneLayout(configuration='vertical2', separatorThickness=1)
    mc.text('<<')
    mc.text('>>')
    mc.setParent('..')

    for v in (10,20,50,80,90,100,110,120,150):
        mc.paneLayout(configuration='vertical2',separatorThickness=1)

        mc.button(label=str(v)+' %', command=partial(weightPrevious,v/100.0))
        mc.button(label=str(v)+' %', command=partial(weightNext,v/100.0))
        mc.setParent('..')

    mc.showWindow(winName)

    mc.window(winName, edit=True, width=100, height=250) 
Example #2
Source File: ml_breakdown.py    From ml_tools with MIT License 6 votes vote down vote up
def ui():
    '''
    User interface for breakdown
    '''

    with utl.MlUi('ml_breakdown', 'Breakdown Tools', width=400, height=180, info='''Select objects.
Press Breakdown Dragger to create a new key and weight it by dragging in the viewport.
Otherwise use the increment buttons to nudge a key's value toward the next or previous key.''') as win:

        win.buttonWithPopup(label='Breakdown Dragger', command=drag, annotation='Drag in the viewport to weight a breakdown toward the next or previous frame.',
                            shelfLabel='BDD')

        mc.separator(height=20)
        mc.floatSliderGrp('ml_breakdown_value_floatSlider', value=0.2, field=True, minValue=0, maxValue=2)
        mc.paneLayout(configuration='vertical3',separatorThickness=1)
        win.ButtonWithPopup(label='<<', command=weightPrevious, annotation='Weight toward the previous frame.', shelfLabel='<', shelfIcon='defaultTwoStackedLayout',
                            readUI_toArgs={'weight':'ml_breakdown_value_floatSlider'})
        win.ButtonWithPopup(label='Average', command=weightAverage, annotation='Weight toward the average of the next and previous frame.', shelfLabel='><', shelfIcon='defaultTwoStackedLayout',
                            readUI_toArgs={'weight':'ml_breakdown_value_floatSlider'})
        win.ButtonWithPopup(label='>>', command=weightNext, annotation='Weight toward the next frame.', shelfLabel='>', shelfIcon='defaultTwoStackedLayout',
                            readUI_toArgs={'weight':'ml_breakdown_value_floatSlider'}) 
Example #3
Source File: ml_centerOfMass.py    From ml_tools with MIT License 6 votes vote down vote up
def buildMainLayout(self):
        '''Build the main part of the ui
        '''
        #self.cbBakeOnes = mc.checkBoxGrp(label='Bake on Ones',
                                         #annotation='Bake every frame. If deselected, the tool will preserve keytimes.')

        #mc.separator()
        self.ButtonWithPopup(label='Create Live COM',
                             command=createCenterOfMass,
                             annotation='Create a constrained COM node based on selected Root Control.')

        mc.paneLayout(configuration='vertical2',separatorThickness=1)
        self.ButtonWithPopup(label='Transfer Root Anim to COM',
                             command=bakeCenterOfMass,
                             annotation='Bake out the Root animation to the COM node.')
        self.ButtonWithPopup(label='Transfer COM back to Root',
                             command=bakeRoot,
                             annotation='A previously baked COM will be baked back to its corresponding Root.')
        mc.setParent('..') 
Example #4
Source File: utils.py    From mgear_core with MIT License 5 votes vote down vote up
def viewport_off(func):
    """Decorator - Turn off Maya display while func is running.

    if func will fail, the error will be raised after.

    type: (function) -> function

    """
    @wraps(func)
    def wrap(*args, **kwargs):
        # type: (*str, **str) -> None

        # Turn $gMainPane Off:
        gMainPane = mel.eval('global string $gMainPane; $temp = $gMainPane;')
        cmds.paneLayout(gMainPane, edit=True, manage=False)

        try:
            return func(*args, **kwargs)

        except Exception as e:
            raise e

        finally:
            cmds.paneLayout(gMainPane, edit=True, manage=True)

    return wrap 
Example #5
Source File: ml_goToKeyframe.py    From ml_tools with MIT License 5 votes vote down vote up
def ui():
    '''
    user interface for ml_goToKeyframe
    '''

    with utl.MlUi('ml_goToKeyframe', 'Go To Keyframe', width=400, height=130, info='''Press Next and Previous to advance time to the next or previous keyframes
within the graph editor or your selection.
Check Round to Nearest Frame to avoid stopping time on non-whole frames.''') as win:

        mc.checkBoxGrp('ml_goToKeyframe_selected_checkBox',
                       label='Within Selection',
                       annotation='Only search for next and previous within the selected keys.',
                       changeCommand=uiSetCheckBox)
        mc.checkBoxGrp('ml_goToKeyframe_selectKeys_checkBox',
                       label='Select Keys',
                       annotation='Select the keyframe(s) on the frame navigated to.',
                       changeCommand=uiSetCheckBox)
        mc.checkBoxGrp('ml_goToKeyframe_round_checkBox',
                       label='Round to Nearest Frame',
                       annotation='Only go to whole-number frames, even if keys are on sub-frames.')
        mc.checkBoxGrp('ml_goToKeyframe_hierarchy_checkBox',
                       label='Search Hierarchy',
                       annotation='Go to the next or previous keyframe in the whole hierarchy.')

        mc.paneLayout(configuration='vertical2', separatorThickness=1)

        win.ButtonWithPopup(label='<< Previous', name=win.name, command=previous,
                            annotation='Go to previous keyframe.',
                            readUI_toArgs={'roundFrame':'ml_goToKeyframe_round_checkBox',
                                           'selected':'ml_goToKeyframe_selected_checkBox',
                                           'selectKeys':'ml_goToKeyframe_selectKeys_checkBox',
                                           'searchHierarchy':'ml_goToKeyframe_hierarchy_checkBox'})

        win.ButtonWithPopup(label='Next >>', name=win.name, command=next,
                            annotation='Go to next keyframe.',
                            readUI_toArgs={'roundFrame':'ml_goToKeyframe_round_checkBox',
                                           'selected':'ml_goToKeyframe_selected_checkBox',
                                           'selectKeys':'ml_goToKeyframe_selectKeys_checkBox',
                                           'searchHierarchy':'ml_goToKeyframe_hierarchy_checkBox'})
        mc.setParent('..') 
Example #6
Source File: dpTranslator.py    From dpAutoRigSystem with GNU General Public License v2.0 4 votes vote down vote up
def dpGetLangStringUI(self, *args):
        """ Show main UI in order to get user translated input texts.
            It will call update UI to start using predefined list of user info.
        """
        self.dpClearTranslatorUI(2)
        
        # translator UI:
        dpARTranslatorWin2 = cmds.window('dpARTranslatorWin2', title=self.translatorString, iconName='dpAutoRig', widthHeight=(400, 400), menuBar=False, sizeable=True, minimizeButton=True, maximizeButton=True)
        dpARTranslatorLayout = cmds.columnLayout('dpARTranslatorLayout', adjustableColumn=True, columnOffset=('both', 10), rowSpacing=10, parent=dpARTranslatorWin2)
        cmds.separator(style='none', parent=dpARTranslatorLayout)
        langNameLayout = cmds.rowColumnLayout('langNameLayout', numberOfColumns=2, columnWidth=[(1, 70), (2, 200)], columnAlign=[(1, 'right'), (2, 'left')], columnAttach=[(1, 'right', 5), (2, 'left', 0)], parent=dpARTranslatorLayout)
        cmds.text('langNameTxt', label=self.langDic[self.langName]['i151_language']+":", parent=langNameLayout)
        cmds.text('newLangNameTxt', label=self.newLangName, parent=langNameLayout)
        # counter:
        counterLayout = cmds.rowColumnLayout('counterLayout', numberOfColumns=4, columnWidth=[(1, 70), (2, 20), (3, 10), (4, 30)], columnAlign=[(1, 'right'), (2, 'left'), (3, 'center'), (4, 'left')], columnAttach=[(1, 'right', 5), (2, 'left', 0), (3, 'left', 5), (4, 'left', 5)], parent=dpARTranslatorLayout)
        cmds.text('sentenceTxt', label=self.langDic[self.langName]['i136_sentence']+":", parent=counterLayout)
        self.curIndexTxt = cmds.text('curIndexTxt', label='0', parent=counterLayout)
        cmds.text('counterHifenTxt', label='/', parent=counterLayout)
        cmds.text('keyLenTxt', label=self.keyLen, parent=counterLayout)
        # lang Key Type:
        langKeyTypeLayout = cmds.rowColumnLayout('langKeyTypeLayout', numberOfColumns=2, columnWidth=[(1, 70), (2, 200)], columnAlign=[(1, 'right'), (2, 'left')], columnAttach=[(1, 'right', 5), (2, 'left', 0)], parent=dpARTranslatorLayout)
        cmds.text('langKeyTypeTxt', label=self.langDic[self.langName]['i138_type']+":", parent=langKeyTypeLayout)
        self.keyTypeTxt = cmds.text('keyTypeTxt', label='0', parent=langKeyTypeLayout)
        # lang Key ID:
        langKeyLayout = cmds.rowColumnLayout('langKeyLayout', numberOfColumns=2, columnWidth=[(1, 70), (2, 200)], columnAlign=[(1, 'right'), (2, 'left')], columnAttach=[(1, 'right', 5), (2, 'left', 0)], parent=dpARTranslatorLayout)
        cmds.text('langKeyIDTxt', label=self.langDic[self.langName]['i137_id']+":", parent=langKeyLayout)
        self.keyIDTxt = cmds.text('keyIDTxt', label='0', parent=langKeyLayout)
        # translator text scrollFields:
        textsPL = cmds.paneLayout('textsPL', configuration='horizontal2', parent=dpARTranslatorLayout)
        self.sourceTextSF = cmds.scrollField('sourceTextSF', editable=False, wordWrap=False, text='', parent=textsPL)
        self.newLangTextSF = cmds.scrollField('newLangTextSF', editable=True, wordWrap=False, text='', parent=textsPL)
        self.extraInfoTxt = cmds.text('extraInfoTxt', label='', parent=dpARTranslatorLayout)
        # translator buttons:
        buttonsPL = cmds.paneLayout('buttonsPL', configuration='vertical3', parent=dpARTranslatorLayout)
        self.backBT = cmds.button('backBT', label=self.langDic[self.langName]['i145_back'], backgroundColor=(0.3, 0.6, 0.7), command=self.dpTranslatorBack, parent=buttonsPL)
        self.sameBT = cmds.button('sameBT', label=self.langDic[self.langName]['i146_same'], backgroundColor=(0.2, 0.8, 0.9), command=self.dpTranslatorSame, parent=buttonsPL)
        self.nextBT = cmds.button('nextBT', label=self.langDic[self.langName]['i147_next'], backgroundColor=(0.1, 0.9, 1.0), command=self.dpTranslatorNext, parent=buttonsPL)
        self.finishBT = cmds.button('finishBT', label=self.langDic[self.langName]['i148_finish'], backgroundColor=(0.8, 0.8, 0.8), enable=False, command=self.dpTranslatorFinish, parent=dpARTranslatorLayout)
        cmds.separator(style='none', parent=dpARTranslatorLayout)
        cmds.showWindow(dpARTranslatorWin2)
        
        # update translator UI:
        self.dpTranslatorUpdateUI() 
Example #7
Source File: capture.py    From pyblish-bumpybox with GNU Lesser General Public License v3.0 4 votes vote down vote up
def _independent_panel(width, height, off_screen=False):
    """Create capture-window context without decorations

    Arguments:
        width (int): Width of panel
        height (int): Height of panel

    Example:
        >>> with _independent_panel(800, 600):
        ...   cmds.capture()

    """

    # center panel on screen
    screen_width, screen_height = _get_screen_size()
    topLeft = [int((screen_height-height)/2.0),
               int((screen_width-width)/2.0)]

    window = cmds.window(width=width,
                         height=height,
                         topLeftCorner=topLeft,
                         menuBarVisible=False,
                         titleBar=False,
                         visible=not off_screen)
    cmds.paneLayout()
    panel = cmds.modelPanel(menuBarVisible=False,
                            label='CapturePanel')

    # Hide icons under panel menus
    bar_layout = cmds.modelPanel(panel, q=True, barLayout=True)
    cmds.frameLayout(bar_layout, edit=True, collapse=True)

    if not off_screen:
        cmds.showWindow(window)

    # Set the modelEditor of the modelPanel as the active view so it takes
    # the playback focus. Does seem redundant with the `refresh` added in.
    editor = cmds.modelPanel(panel, query=True, modelEditor=True)
    cmds.modelEditor(editor, edit=True, activeView=True)

    # Force a draw refresh of Maya so it keeps focus on the new panel
    # This focus is required to force preview playback in the independent panel
    cmds.refresh(force=True)

    try:
        yield panel
    finally:
        # Delete the panel to fix memory leak (about 5 mb per capture)
        cmds.deleteUI(panel, panel=True)
        cmds.deleteUI(window) 
Example #8
Source File: capture.py    From maya-capture with MIT License 4 votes vote down vote up
def _independent_panel(width, height, off_screen=False):
    """Create capture-window context without decorations

    Arguments:
        width (int): Width of panel
        height (int): Height of panel

    Example:
        >>> with _independent_panel(800, 600):
        ...   cmds.capture()

    """

    # center panel on screen
    screen_width, screen_height = _get_screen_size()
    topLeft = [int((screen_height-height)/2.0),
               int((screen_width-width)/2.0)]

    window = cmds.window(width=width,
                         height=height,
                         topLeftCorner=topLeft,
                         menuBarVisible=False,
                         titleBar=False,
                         visible=not off_screen)
    cmds.paneLayout()
    panel = cmds.modelPanel(menuBarVisible=False,
                            label='CapturePanel')

    # Hide icons under panel menus
    bar_layout = cmds.modelPanel(panel, q=True, barLayout=True)
    cmds.frameLayout(bar_layout, edit=True, collapse=True)

    if not off_screen:
        cmds.showWindow(window)

    # Set the modelEditor of the modelPanel as the active view so it takes
    # the playback focus. Does seem redundant with the `refresh` added in.
    editor = cmds.modelPanel(panel, query=True, modelEditor=True)
    cmds.modelEditor(editor, edit=True, activeView=True)

    # Force a draw refresh of Maya so it keeps focus on the new panel
    # This focus is required to force preview playback in the independent panel
    cmds.refresh(force=True)

    try:
        yield panel
    finally:
        # Delete the panel to fix memory leak (about 5 mb per capture)
        cmds.deleteUI(panel, panel=True)
        cmds.deleteUI(window) 
Example #9
Source File: ml_stopwatch.py    From ml_tools with MIT License 4 votes vote down vote up
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.')