Python maya.cmds.button() Examples

The following are 30 code examples of maya.cmds.button(). 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: createSpiralWin.py    From tutorials with MIT License 7 votes vote down vote up
def createSpiralWin():
    window = cmds.window( title="Create Spiral", widthHeight=(200, 300) )
    cmds.columnLayout( columnAttach=('both', 5), rowSpacing=5, adjustableColumn=True )
    
    amp = cmds.floatFieldGrp( numberOfFields=1, label='Amp', value1=1.0)
    spin = cmds.floatFieldGrp( numberOfFields=1, label='Spin', value1=30)
    count = cmds.intFieldGrp( numberOfFields=1, label='Count', value1=20)
    width = cmds.floatFieldGrp( numberOfFields=1, label='Width', value1=3)

    def click(value):
        doCreateSpiral(amp, spin, count, width)
        
    cmds.button( label='Create Spiral!', command=click )
    
    closeCmd = 'cmds.deleteUI("%s", window=True)' % window
    cmds.button( label='Close', command=closeCmd )
    
    cmds.showWindow( window ) 
Example #2
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 #3
Source File: ml_utilities.py    From ml_tools with MIT License 7 votes vote down vote up
def buttonWithPopup(self, label=None, command=None, annotation='', shelfLabel='', shelfIcon='render_useBackground', readUI_toArgs={}):
        '''
        Create a button and attach a popup menu to a control with options to create a shelf button or a hotkey.
        The argCommand should return a kwargs dictionary that can be used as args for the main command.
        '''

        if self.icon:
            shelfIcon = self.icon

        if annotation and not annotation.endswith('.'):
            annotation+='.'

        button = mc.button(label=label, command=command, annotation=annotation+' Or right click for more options.')

        mc.popupMenu()
        self.shelfMenuItem(command=command, annotation=annotation, shelfLabel=shelfLabel, shelfIcon=shelfIcon)
        self.hotkeyMenuItem(command=command, annotation=annotation)
        return button 
Example #4
Source File: ml_arcTracer.py    From ml_tools with MIT License 6 votes vote down vote up
def mini():
    name = 'ml_arcTracer_win_mini'
    w = 100
    h = 50
    if mc.window(name, exists=True):
        mc.deleteUI(name)
    win = mc.window(name, width=w, height=h, title='arcs', iconName='arc')
    form = mc.formLayout()

    a1 = mc.button(label='camera', command=traceCamera)
    a2 = mc.button(label='world', command=traceWorld)
    b1 = mc.button(label='retrace', command=retraceArc)
    b2 = mc.button(label='clear', command=clearArcs)

    utl.formLayoutGrid(form, [[a1,a2],[b1,b2]], )

    mc.showWindow(win)
    mc.window(win, edit=True, width=w, height=h) 
Example #5
Source File: dpIkFkSnap.py    From dpAutoRigSystem with GNU General Public License v2.0 6 votes vote down vote up
def dpIkFkSnapUI(self, *args):
        """ Show a little window with buttons to change from Ik to Fk or from Fk to Ik snapping.
        """
        # creating ikFkSnap Window:
        if cmds.window('dpIkFkSnapWindow', query=True, exists=True):
            cmds.deleteUI('dpIkFkSnapWindow', window=True)
        ikFkSnap_winWidth  = 205
        ikFkSnap_winHeight = 50
        dpIkFkSnapWin = cmds.window('dpIkFkSnapWindow', title='IkFkSnap '+DPIKFK_VERSION, iconName='dpIkFkSnap', widthHeight=(ikFkSnap_winWidth, ikFkSnap_winHeight), menuBar=False, sizeable=True, minimizeButton=True, maximizeButton=False, menuBarVisible=False, titleBar=True)
        # creating layout:
        ikFkSnapLayout = cmds.columnLayout('ikFkSnapLayout', adjustableColumn=True, parent=dpIkFkSnapWin)
        # creating buttons:
        cmds.button('ikToFkSnap_BT', label="Ik --> Fk", backgroundColor=(0.8, 0.8, 1.0), command=self.IkToFkSnap, parent=ikFkSnapLayout)
        cmds.button('fkToIkSnap_BT', label="Fk --> Ik", backgroundColor=(1.0, 0.8, 0.8), command=self.FkToIkSnap, parent=ikFkSnapLayout)
        # call colorIndex Window:
        cmds.showWindow(dpIkFkSnapWin) 
Example #6
Source File: dpAutoRig.py    From dpAutoRigSystem with GNU General Public License v2.0 6 votes vote down vote up
def donateWin(self, *args):
        """ Simple window with links to donate in order to support this free and openSource code via PayPal.
        """
        # declaring variables:
        self.donate_title       = 'dpAutoRig - v'+DPAR_VERSION+' - '+self.langDic[self.langName]['i167_donate']
        self.donate_description = self.langDic[self.langName]['i168_donateDesc']
        self.donate_winWidth    = 305
        self.donate_winHeight   = 300
        self.donate_align       = "center"
        # creating Donate Window:
        if cmds.window('dpDonateWindow', query=True, exists=True):
            cmds.deleteUI('dpDonateWindow', window=True)
        dpDonateWin = cmds.window('dpDonateWindow', title=self.donate_title, iconName='dpInfo', widthHeight=(self.donate_winWidth, self.donate_winHeight), menuBar=False, sizeable=True, minimizeButton=False, maximizeButton=False)
        # creating text layout:
        donateColumnLayout = cmds.columnLayout('donateColumnLayout', adjustableColumn=True, columnOffset=['both', 20], rowSpacing=5, parent=dpDonateWin)
        cmds.separator(style='none', height=10, parent=donateColumnLayout)
        infoDesc = cmds.text(self.donate_description, align=self.donate_align, parent=donateColumnLayout)
        cmds.separator(style='none', height=10, parent=donateColumnLayout)
        brPaypalButton = cmds.button('brlPaypalButton', label=self.langDic[self.langName]['i167_donate']+" - R$ - Real", align=self.donate_align, command=partial(utils.visitWebSite, DONATE+"BRL"), parent=donateColumnLayout)
        #usdPaypalButton = cmds.button('usdPaypalButton', label=self.langDic[self.langName]['i167_donate']+" - USD - Dollar", align=self.donate_align, command=partial(utils.visitWebSite, DONATE+"USD"), parent=donateColumnLayout)
        # call Donate Window:
        cmds.showWindow(dpDonateWin) 
Example #7
Source File: ml_stopwatch.py    From ml_tools with MIT License 6 votes vote down vote up
def ui():
    '''
    User interface for stopwatch
    '''

    with utl.MlUi('ml_stopwatch', 'Stopwatch', width=400, height=175, info='''Press the start button to start recording.
Continue pressing to set marks.
When finished, press the stop button and the report will pop up.''') as win:

        mc.checkBoxGrp('ml_stopwatch_round_checkBox',label='Round to nearest frame', value1=True, annotation='Only whole number frames')

        mc.text('ml_stopwatch_countdown_text', label='Ready...')

        mc.button('ml_stopwatch_main_button', label='Start', height=80)
        _setButtonStart()
        mc.button(label='Stop', command=_stopButton, annotation='Stop the recording.') 
Example #8
Source File: ml_copySkin.py    From ml_tools with MIT License 6 votes vote down vote up
def __init__(self):

        super(CopySkinUI, self).__init__('ml_copySkin', 'Copy SkinClusters', width=400, height=180,
                                         info='''Select a skinned mesh to add to the Source Mesh field below.
Select a destination mesh, or vertices to copy the skin to.
Press the button to copy the skin weights.''')

        self.buildWindow()

        self.srcMeshField = self.selectionField(label='Source Mesh',
                                                annotation='Select the mesh to be used as the source skin.',
                                                channel=False,
                                                text='')

        mc.button(label='Copy Skin', command=self.copySkin, annotation='Copy the Source Skin to selection.')

        self.finish() 
Example #9
Source File: ml_utilities.py    From ml_tools with MIT License 6 votes vote down vote up
def __init__(self, label=None, name=None, command=None, annotation='', shelfLabel='', shelfIcon='render_useBackground', readUI_toArgs={}, **kwargs):
            '''
            The fancy part of this object is the readUI_toArgs argument.
            '''

            self.uiArgDict = readUI_toArgs
            self.name = name
            self.command = command
            self.kwargs = kwargs

            self.annotation = annotation
            self.shelfLabel = shelfLabel
            self.shelfIcon = shelfIcon

            if annotation and not annotation.endswith('.'):
                annotation+='.'

            button = mc.button(label=label, command=self.runCommand, annotation=annotation+' Or right click for more options.')

            mc.popupMenu()
            mc.menuItem(label='Create Shelf Button', command=self.createShelfButton, image=shelfIcon)

            mc.menuItem(label='Create Hotkey',
                        command=self.createHotkey, image='commandButton') 
Example #10
Source File: ml_utilities.py    From ml_tools with MIT License 6 votes vote down vote up
def upToDateCheck(revision, prompt=True):
    '''
    This is a check that can be run by scripts that import ml_utilities to make sure they
    have the correct version.
    '''

    if not '__revision__' in locals():
        return

    if revision > __revision__:
        if prompt and mc.optionVar(query='ml_utilities_revision') < revision:
            result = mc.confirmDialog( title='Module Out of Date',
                                       message='Your version of ml_utilities may be out of date for this tool. Without the latest file you may encounter errors.',
                                       button=['Download Latest Revision','Ignore', "Don't Ask Again"],
                                       defaultButton='Download Latest Revision', cancelButton='Ignore', dismissString='Ignore' )

            if result == 'Download Latest Revision':
                mc.showHelp(GITHUB_ROOT_URL+'ml_utilities.py', absolute=True)
            elif result == "Don't Ask Again":
                mc.optionVar(intValue=('ml_utilities_revision', revision))
        return False
    return True 
Example #11
Source File: ml_utilities.py    From ml_tools with MIT License 6 votes vote down vote up
def about(self, *args):
        '''
        This pops up a window which shows the revision number of the current script.
        '''

        text='by Morgan Loomis\n\n'
        try:
            __import__(self.module)
            module = sys.modules[self.module]
            text = text+'Revision: '+str(module.__revision__)+'\n'
        except StandardError:
            pass
        try:
            text = text+'ml_utilities Rev: '+str(__revision__)+'\n'
        except StandardError:
            pass

        mc.confirmDialog(title=self.name, message=text, button='Close') 
Example #12
Source File: dpLayoutClass.py    From dpAutoRigSystem with GNU General Public License v2.0 6 votes vote down vote up
def colorizeModuleUI(self, colorIndex, *args):
        """ Show a little window to choose the color of the button and the override the guide.
        """
        # verify integrity of the guideModule:
        if self.verifyGuideModuleIntegrity():
            # creating colorIndex Window:
            if cmds.window('dpColorIndexWindow', query=True, exists=True):
                cmds.deleteUI('dpColorIndexWindow', window=True)
            colorIndex_winWidth  = 160
            colorIndex_winHeight = 80
            self.dpColorIndexWin = cmds.window('dpColorIndexWindow', title='Color Index', iconName='dpColorIndex', widthHeight=(colorIndex_winWidth, colorIndex_winHeight), menuBar=False, sizeable=False, minimizeButton=False, maximizeButton=False, menuBarVisible=False, titleBar=True)
            # creating layout:
            colorIndexLayout = cmds.gridLayout('colorIndexLayout', numberOfColumns=8, cellWidthHeight=(20,20))
            # creating buttons:
            for colorIndex, colorValues in enumerate(self.colorList):
                cmds.button('indexColor_'+str(colorIndex)+'_BT', label=str(colorIndex), backgroundColor=(colorValues[0], colorValues[1], colorValues[2]), command=partial(self.setColorModule, colorIndex), parent=colorIndexLayout)
            # call colorIndex Window:
            cmds.showWindow(self.dpColorIndexWin) 
Example #13
Source File: optionbox.py    From cmt with MIT License 6 votes vote down vote up
def __init__(self, title, help_url=None):
        layout = mel.eval("getOptionBox")
        cmds.setParent(layout)
        mel.eval('setOptionBoxTitle("{}");'.format(title))
        self.create_ui()

        apply_close_button = mel.eval("getOptionBoxApplyAndCloseBtn;")
        cmds.button(apply_close_button, e=True, command=self._apply_and_close)
        apply_button = mel.eval("getOptionBoxApplyBtn;")
        cmds.button(apply_button, e=True, command=self._on_apply)
        close_button = mel.eval("getOptionBoxCloseBtn;")
        cmds.button(close_button, e=True, command=self._close)

        if help_url:
            help_item = mel.eval("getOptionBoxHelpItem;")
            cmds.menuItem(
                help_item,
                e=True,
                label="Help on {}".format(title),
                command='import webbrowser; webbrowser.open("{}")'.format(help_url),
            ) 
Example #14
Source File: ml_convertRotationOrder.py    From ml_tools with MIT License 6 votes vote down vote up
def ui():
    '''
    User interface for convert rotation order
    '''

    with utl.MlUi('ml_convertRotationOrder', 'Convert Rotation Order', width=400, height=140, info='''Select objects to convert and press button for desired rotation order.
Use the "Get Tips" button to see suggestions for a single object on the current frame.''') as win:


        mc.button(label='Get tips for selection', command=loadTips, annotation='')
        mc.scrollField('ml_convertRotationOrder_nodeInfo_scrollField', editable=False, wordWrap=True, height=60)

        mc.rowColumnLayout(numberOfColumns=2, columnWidth=[(1,100), (2,400)], columnAttach=[2,'both',1])
        for each in ROTATE_ORDERS:
            _BUTTON[each] = win.buttonWithPopup(label=each, command=globals()[each], annotation='Convert selected object rotate order to '+each+'.', shelfLabel=each)
            mc.textField('ml_convertRotationOrder_'+each+'_textField', editable=False)

    resetTips() 
Example #15
Source File: ml_colorControl.py    From ml_tools with MIT License 6 votes vote down vote up
def colorControlLayout(self, label=''):
        mc.rowLayout( numberOfColumns=4,
                      columnWidth4=(150, 200, 90, 80),
                      adjustableColumn=2,
                      columnAlign=(1, 'right'),
                      columnAttach=[(1, 'both', 0),
                                    (2, 'both', 0),
                                    (3, 'both', 0),
                                    (4, 'both', 0)] )
        mc.text(label=label)
        colorSlider = mc.colorSliderGrp( label='', adj=2, columnWidth=((1,1),(3,1)))
        mc.button(label='From Selected',
                  ann='Get the color of the selected object.',
                  command=partial(self.setFromSelected, colorSlider))
        mc.button(label='Randomize',
                  ann='Set a random color.',
                  command=partial(self.randomizeColors, colorSlider))
        controls = mc.layout(colorSlider, query=True, childArray=True)

        mc.setParent('..')

        return colorSlider 
Example #16
Source File: ml_puppet.py    From ml_tools with MIT License 5 votes vote down vote up
def __init__(self, title='SpaceSwitch', width=400, height=200):
        
        
        sel = mc.ls(sl=True)
        if not sel:
            return 
        
        spaces = None
        nodes = []
        for each in sel:
            data = getSpaceSwitchData(each)
            if not data:
                continue
            nodes.append(each)
            theseSpaces = set(data['space']['enumValues'])
            if not spaces:
                spaces = theseSpaces
            else:
                spaces.intersection(theseSpaces)
        
        if not spaces:
            return
        
        self.width = width
        self.height = height
        
        self.close()

        mc.window(self.win_name, title=title, iconName=title, width=self.width, height=self.height, menuBar=True)
        self.column = mc.columnLayout(adj=True)
        
        for space in list(spaces):
            mc.button(space, command=partial(self.setSpace, nodes, space))
        
        self.show() 
Example #17
Source File: ml_utilities.py    From ml_tools with MIT License 5 votes vote down vote up
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(TOOL_URL+self.name+'/')))

        mc.text(label=self.info)
        mc.setParent('..')
        mc.separator(height=8, style='single', horizontal=True) 
Example #18
Source File: ml_utilities.py    From ml_tools with MIT License 5 votes vote down vote up
def drag(self, *args):
        '''
        This is what is actually run during the drag, updating the coordinates and calling the
        placeholder drag functions depending on which button is pressed.
        '''

        self.dragPoint = mc.draggerContext(self.draggerContext, query=True, dragPoint=True)

        #if this doesn't work, try getmodifier
        self.modifier = mc.draggerContext(self.draggerContext, query=True, modifier=True)

        self.x = ((self.dragPoint[0] - self.anchorPoint[0]) * self.multiplier) + self.defaultValue
        self.y = ((self.dragPoint[1] - self.anchorPoint[1]) * self.multiplier) + self.defaultValue

        if self.minValue is not None and self.x < self.minValue:
            self.x = self.minValue
        if self.maxValue is not None and self.x > self.maxValue:
            self.x = self.maxValue

        #dragString
        if self.modifier == 'control':
            if self.button == 1:
                self.dragControlLeft(*args)
            elif self.button == 2:
                self.dragControlMiddle(*args)
        elif self.modifier == 'shift':
            if self.button == 1:
                self.dragShiftLeft(*args)
            elif self.button == 2:
                self.dragShiftMiddle(*args)
        else:
            if self.button == 1:
                self.dragLeft()
            elif self.button == 2:
                self.dragMiddle()

        mc.refresh() 
Example #19
Source File: ml_utilities.py    From ml_tools with MIT License 5 votes vote down vote up
def createShelfButton(self,*args):
            '''
            Builds the command and creates a shelf button out of it
            '''
            self.readUI()
            pythonCommand = self.stringCommand()
            createShelfButton(pythonCommand, self.shelfLabel, self.name, description=self.annotation, image=self.shelfIcon) 
Example #20
Source File: ml_controlLibrary.py    From ml_tools with MIT License 5 votes vote down vote up
def deleteShelfButton(self, name, *args):
        '''Delete the shelf button
        '''

        #at the moment this crashes my maya. Need to investigate before including.
        path = controlFilePath(name)
        os.remove(path)
        os.remove(path.replace('.ctrl','.png'))
        self.refreshShelfLayout() 
Example #21
Source File: ml_controlLibrary.py    From ml_tools with MIT License 5 votes vote down vote up
def buildMainLayout(self):
        '''Build the main part of the ui
        '''

        tabs = mc.tabLayout()
        tab1 = mc.columnLayout(adj=True)

        mc.scrollLayout(cr=True)
        self.shelfLayout = mc.shelfLayout()

        self.refreshShelfLayout()

        mc.setParent(tabs)

        tab2 = mc.columnLayout(adj=True)

        mc.separator(height=8, style='none')
        mc.text('Select curve(s) to export. Multiple selected curves will be combined.')
        mc.text('Center and fit the curve in the viewport,')
        mc.text('and make sure nothing else is visible for best icon creation.')
        mc.separator(height=16, style='in')

        mc.button('Export Selected Curve', command=self.exportControl, annotation='Select a nurbsCurve to export.')

        mc.tabLayout( tabs, edit=True, tabLabel=((tab1, 'Import'),
                                                 (tab2, 'Export')
                                                 ))

        if not mc.shelfLayout(self.shelfLayout, query=True, numberOfChildren=True):
            mc.tabLayout( tabs, edit=True, selectTab=tab2) 
Example #22
Source File: ml_controlLibrary.py    From ml_tools with MIT License 5 votes vote down vote up
def ui():
    '''Launch the UI
    '''
    if not os.path.exists(REPOSITORY_PATH):
        result = mc.confirmDialog( title='Control Repository Not Found', message='Create a repository directory?',
                                   button=['Create','Cancel'], defaultButton='Cancel', cancelButton='Cancel', dismissString='Cancel' )

        if result != 'Create':
            return None

        os.mkdir(REPOSITORY_PATH)

    win = ControlLibraryUI()
    win.buildMainLayout()
    win.finish() 
Example #23
Source File: ml_colorControl.py    From ml_tools with MIT License 5 votes vote down vote up
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')) ) 
Example #24
Source File: ml_colorControl.py    From ml_tools with MIT License 5 votes vote down vote up
def __init__(self):

        super(ColorControlUI, self).__init__('ml_colorControl',
                                               'Color Controls',
                                               width=400,
                                               height=175,
                                               info='''Color control curves or other nodes.
Color a selected list of nodes as a gradient from one color to another.
Set the first and last color, make a selection, and press the button.''')
        self.colorSliders = []
        self.buildWindow() 
Example #25
Source File: optionbox.py    From cmt with MIT License 5 votes vote down vote up
def _on_apply(self, *args):
        """Call back called when the Apply button is pressed.

        The only reason this method exists is so the derived on_apply doesn't have to
        have any args.

        :param args: Callback args.
        """
        self.on_apply() 
Example #26
Source File: ml_stopwatch.py    From ml_tools with MIT License 5 votes vote down vote up
def stop(self):
        '''
        Stop the stopwatch and convert the time to frames.
        '''

        if not self.markTime:
            OpenMaya.MGlobal.displayWarning('No marks recorded, the "Mark" button needs to be pressed at least once after recording is started.')
            return

        #don't mark the last frame
        #self.mark()
        self.elapsed = self.markTime[-1] - self.startTime

        #mark frames
        self.frameMarks = [0]
        for m in self.markTime:

            seconds = m - self.startTime
            frame = (seconds*self.frameRate)
            frame = round(frame, self.roundTo)

            if not self.roundTo:
                frame = int(frame)

            self.frameMarks.append(frame)

        self.ui() 
Example #27
Source File: menu.py    From cmt with MIT License 5 votes vote down vote up
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) 
Example #28
Source File: reusableUI.py    From PythonForMayaSamples with GNU General Public License v3.0 5 votes vote down vote up
def buildUI(self):
        column = cmds.columnLayout()
        cmds.text(label="Use this slider to set the tween amount")

        cmds.rowLayout(numberOfColumns=2)
        self.slider = cmds.floatSlider(min=0, max=100, value=50, step=1, changeCommand=tweener.tween)
        cmds.button(label="Reset", command=self.reset)

        cmds.setParent(column)
        cmds.button(label="Close", command=self.close)

    # And again, we just need to override the reset method
    # We don't need to define the close, or show methods because it gets those from BaseWindow 
Example #29
Source File: tweener.py    From PythonForMayaSamples with GNU General Public License v3.0 5 votes vote down vote up
def buildUI(self):
        # To start with we create a layout to hold our UI objects
        # A layout is a UI object that lays out its children, in this case in a column
        column = cmds.columnLayout()

        # Now we create a text label to tell a user how to use our UI
        cmds.text(label="Use this slider to set the tween amount")

        # We want to put our slider and a button side by side. This is not possible in a columnLayout, so we use a row
        row = cmds.rowLayout(numberOfColumns=2)

        # We create a slider, set its minimum, maximum and default value.
        # The changeCommand needs to be given a function to call, so we give it our tween function
        # We need to hold on to our slider's name so we can edit it later, so we hold it in a variable
        self.slider = cmds.floatSlider(min=0, max=100, value=50, step=1, changeCommand=tween)

        # Now we make a button to reset our UI, and it calls our reset method
        cmds.button(label="Reset", command=self.reset)

        # Finally we don't want to add anymore to our row layout but want to add it to our column again
        # So we must change the active parent layout
        cmds.setParent(column)

        # We add a button to close our UI
        cmds.button(label="Close", command=self.close)

    # *args will be a new concept for you
    # It basically means I do not know how many arguments I will get, so please put them all inside this one list (tuple) called args 
Example #30
Source File: ml_convertRotationOrder.py    From ml_tools with MIT License 5 votes vote down vote up
def resetTips():

    #clear the tips
    for each in ROTATE_ORDERS:
        mc.button(_BUTTON[each], edit=True, enable=True)
        mc.textField('ml_convertRotationOrder_'+each+'_textField', edit=True, text='')

    #set default tips
    mc.textField('ml_convertRotationOrder_xyz_textField', edit=True, text='Default Maya rotation order, for x-oriented joints.')
    mc.textField('ml_convertRotationOrder_zxy_textField', edit=True, text='Ideal for worldspace controls.')
    mc.textField('ml_convertRotationOrder_xzy_textField', edit=True, text='Ideal for worldspace controls.')