本文整理汇总了Python中maya.cmds.button函数的典型用法代码示例。如果您正苦于以下问题:Python button函数的具体用法?Python button怎么用?Python button使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了button函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: snapOnClosestVertex_window
def snapOnClosestVertex_window():
"""
Creates the 'Snap On Closest Vertex' vertex window.
"""
cmds.windowPref(enableAll=False)
if (cmds.window("snapOnClosestVertex_window", exists=True)):
cmds.deleteUI("snapOnClosestVertex_window")
cmds.window("snapOnClosestVertex_window",
title="Snap On Closest Vertex",
width=320)
spacing = 5
cmds.columnLayout(adjustableColumn=True, rowSpacing=spacing)
cmds.rowLayout(numberOfColumns=3, columnWidth3=(125, 150, 130), adjustableColumn=2, columnAlign=(2, "left"), columnAttach=[(1, "both", spacing), (2, "both", spacing), (3, "both", spacing)])
cmds.text(label="Reference Object:")
referenceObject_textField = cmds.textField("referenceObject_textField")
cmds.button("getReferenceObject_button", label="Get Reference Object!", command=getReferenceObject_button_OnClicked)
cmds.setParent(topLevel=True)
cmds.separator(style="single")
cmds.button("snapIt_button", label="Snap It!", al="center", command=snapIt_button_OnClicked)
cmds.showWindow("snapOnClosestVertex_window")
cmds.windowPref(enableAll=True)
示例2: zbw_offsetAnim
def zbw_offsetAnim(*args):
"""creates offset from first obj sel to last based on the entered offset value"""
def zbw_runOffsetAnim(*args):
#get frame range!!!!!!
#get selection, check that they are tranforms
sel = cmds.ls(sl=True,type="transform")
selSize = int(len(sel))
#for each selection mult the index by the offset value
for i in range(0,selSize):
obj = sel[i]
offsetRaw = cmds.intFieldGrp('zbw_offsetValue', q=True, v=True)
offset = offsetRaw[0]
multFactor = i * offset
#shift the entire anim curve by the offset mult value
cmds.keyframe(obj, edit=True,relative=True,timeChange=multFactor,time=(1,24))
#create UI, get offset value, frame range or all anim
if (cmds.window('zbw_offsetAnimUI', exists=True)):
cmds.deleteUI('zbw_offsetAnimUI', window=True)
cmds.windowPref('zbw_offsetAnimUI', remove=True)
window=cmds.window('zbw_offsetAnimUI', widthHeight=(350,200), title='zbw_offsetAnim')
cmds.columnLayout(cal='center')
cmds.intFieldGrp('zbw_offsetValue', cal=(1,'left'), label='frequency(frames)', value1=5)
#CREATE FRAME RANGE AREA (WHICH FRAMES ARE WE DOING?)
#WHEN THAT HAPPENS, WHAT DO WE DO WITH THE FRAMES AFTER THAT? (PROBABLY NOTHING. . . LET USER WORRY ABOUT IT)
#checkbox for random freq (to give a random amount to offset each object)
#cmds.checkBoxGrp('zbw_animNoiseRandom', cal=(1,'left'), cw=(1, 175),label='random frequency on', value1=0, cc=zbw_animNoiseRandom)
cmds.button('zbw_offsetAnimGo', label='offset!', width=75, command=zbw_runOffsetAnim)
cmds.showWindow(window)
示例3: removeFloatVariable
def removeFloatVariable(self, nodeAttr, varslayout, index):
# Remove variable
children = cmds.columnLayout(varslayout, query=1, childArray=1)
if len(children) <= index:
return
baseNameAttr = nodeAttr
baseValueAttr = nodeAttr.replace("fparam_name", "fparam_value");
for i in xrange(index+1, len(children)):
rembtn, namefld, _, valfld = cmds.formLayout(children[i], query=1, childArray=1)
indexStr = "[%d]" % (i - 1)
nextIndexStr = "[%d]" % i
nameAttr = baseNameAttr + indexStr
valueAttr = baseValueAttr + indexStr
cmds.setAttr(nameAttr, cmds.getAttr(baseNameAttr + nextIndexStr), type="string")
cmds.setAttr(valueAttr, cmds.getAttr(baseValueAttr + nextIndexStr));
self.setupVariableNameCallback(nameAttr, namefld)
self.setupFloatVariableValueCallback(valueAttr, valfld)
cmds.button(rembtn, edit=1, command=lambda *args: self.removeFloatVariable(nodeAttr, varslayout, i-1))
cmds.deleteUI(children[index])
cmds.removeMultiInstance("%s[%d]" % (baseNameAttr, len(children)-1), b=True)
cmds.removeMultiInstance("%s[%d]" % (baseValueAttr, len(children)-1), b=True)
示例4: doIt
def doIt( self, arglist ):
wnd = cmds.window( "kgmEngineWindow_" + str(time.time()), widthHeight = ( 200, 200 ) )
#cmds.columnLayout( adjustableColumn = True )
#cmds.button( label = 'Export Map', command = kgmEngine.exportMap )
#cmds.button( label = 'Export Mesh', command = kgmEngine.exportMesh )
#cmds.button( label = 'Export Skeleton', command = kgmEngine.exportSkeleton )
#cmds.button( label = 'Export Animation', command = kgmEngine.exportAnimation )
#cmds.button( label = 'Insert Node', command = kgmEngine.insertNode )
cmds.columnLayout()
cmds.rowColumnLayout( numberOfColumns = 2 )
cmds.checkBox( "Mesh", label="Mesh", value=False, onCommand=kgmEngine.enableMesh, offCommand=kgmEngine.enableMesh )
cmds.checkBox( "Material", label="Material", value=False, onCommand=kgmEngine.enableMaterial, offCommand=kgmEngine.enableMaterial )
cmds.checkBox( "Skeleton", label="Skeleton", value=False, onCommand=kgmEngine.enableSkeleton, offCommand=kgmEngine.enableSkeleton )
cmds.checkBox( "Animation", label="Animation", value=False, onCommand=kgmEngine.enableAnimation, offCommand=kgmEngine.enableAnimation )
cmds.columnLayout()
cmds.rowColumnLayout( numberOfColumns = 2 )
cmds.columnLayout( adjustableColumn=True )
cmds.button( label = 'Export', command = kgmEngine.export )
cmds.button( label = 'Insert Node', command = kgmEngine.insertNode )
cmds.columnLayout()
cmds.rowColumnLayout( numberOfColumns = 3 )
cmds.columnLayout( adjustableColumn=True )
cmds.radioCollection()
cmds.radioButton( label='Bin', align='left', select=False )
cmds.radioButton( label='Xml', align='left', select=True )
#cmds.radioButtonGrp( label='Format', labelArray3=['Bin', 'Txt', 'Xml'], numberOfRadioButtons=3 )
#cmds.radioButton( 'Format', label='Bin', )
cmds.showWindow( wnd )
示例5: locatorParticlesUI
def locatorParticlesUI():
"""
"""
# Define window
locParticleUI = 'locatorParticleWindow'
if cmds.window(locParticleUI, q=True, ex=True): cmds.deleteUI(locParticleUI)
locParticleUI = cmds.window(locParticleUI, t='Generate Particles')
# UI Layout
cmds.columnLayout(adj=False, cal='left')
partiTFG = cmds.textFieldGrp('locParticle_particleTFG', label='Particle', text='', cw=[(1, 100)])
radiusFFG = cmds.floatSliderGrp('locParticle_radiusFSG', label='radius', f=True, min=0.1, max=10.0, fmn=0.01,
fmx=100.0, pre=2, v=1.0, cw=[(1, 100)])
rotateLocCBG = cmds.checkBoxGrp('locParticle_rotateCBG', label='Add rotatePP', ncb=1, v1=0, cw=[(1, 100)])
scaleLocCBG = cmds.checkBoxGrp('locParticle_scaleCBG', label='Add scalePP', ncb=1, v1=0, cw=[(1, 100)])
selfCollideCBG = cmds.checkBoxGrp('locParticle_selfCollideCBG', label='self collide', ncb=1, v1=0, cw=[(1, 100)])
cmds.button(l='Create Particles', c='glTools.tools.generateParticles.locatorParticlesFromUI()')
# Popup menu
cmds.popupMenu(parent=partiTFG)
for p in cmds.ls(type=['particle', 'nParticle']):
cmds.menuItem(p, c='cmds.textFieldGrp("' + partiTFG + '",e=True,text="' + p + '")')
# Show Window
cmds.showWindow(locParticleUI)
示例6: new
def new(self):
cmds.setParent(self.parent)
self.name = cmds.button(self.name, label=self.label, c=self.cmd, h=self.h)
if self.bgc:
cmds.button(self.name, e=True, bgc=self.bgc)
attachForm = [(self.name, 'bottom', self.moveUp), (self.name, 'right', 0), (self.name, 'left', 0)]
cmds.formLayout(self.parent, edit=True, attachForm=attachForm)
示例7: setAttributeVectorUI
def setAttributeVectorUI():
global tfXIn, tfXOut, tfYIn, tfYOut, tfZIn, tfZOut, tslVectorList, tfXAdd, tfYAdd, tfZAdd, vectorUI
vectorUI = 'vectorUI'
closeUI(vectorUI)
cmds.window(vectorUI, title = 'vectorUI')
cmds.columnLayout(columnAttach = ['both', 5], rowSpacing = 5, columnWidth = 210)
cmds.text('..: random range :..', backgroundColor = [0.15, 0.15, 0.0])
cmds.gridLayout(numberOfColumns = 6, cellWidthHeight = (33, 20))
tfXIn = cmds.textField(text = '0.0', backgroundColor = [0.15, 0.1, 0.0])
tfXOut = cmds.textField(text = '1.0', backgroundColor = [0.15, 0.1, 0.0])
tfYIn = cmds.textField(text = '0.0', backgroundColor = [0.0, 0.15, 0.1])
tfYOut = cmds.textField(text = '1.0', backgroundColor = [0.0, 0.15, 0.1])
tfZIn = cmds.textField(text = '0.0', backgroundColor = [0.0, 0.1, 0.15])
tfZOut = cmds.textField(text = '1.0', backgroundColor = [0.0, 0.1, 0.15])
cmds.setParent('..')
cmds.button('ok', command = 'setAttributeVectorRandom()')
cmds.separator(style = 'out')
cmds.text('..: vector list :..', backgroundColor = [0.0, 0.15, 0.15])
tslVectorList = cmds.textScrollList(allowMultiSelection = True)
cmds.button('remove', command = 'removeScrollListVector()')
cmds.gridLayout(numberOfColumns = 4, cellWidthHeight = (50, 20))
tfXAdd = cmds.textField(text = '0.0', backgroundColor = [0.15, 0.1, 0.0])
tfYAdd = cmds.textField(text = '0.0', backgroundColor = [0.0, 0.15, 0.1])
tfZAdd = cmds.textField(text = '0.0', backgroundColor = [0.0, 0.1, 0.15])
cmds.button('add..', command = 'addScrollListVector()')
cmds.setParent('..')
cmds.button('random', command = 'setAttributeListVectorRandom()')
cmds.button('increment %', command = 'setAttributeListVectorInc()')
cmds.setParent('..')
cmds.showWindow()
示例8: stabilizer
def stabilizer (task):
camera = Camera()
point = cmds.ls (selection = True)
if task == 'end':
# turn off stab
expression = str (cmds.expression ('stabilizator_expression', string = True, query = True))
camera.shape = expression[2:expression.find('#')]
cmds.delete ('stabilizator_expression')
camera.reset_camera ()
cmds.button ('button_stabilizer',
edit = True,
label = 'stabilize',
backgroundColor = (0, 0.5, 0),
command = 'fstab.stabilizer("start")')
else:
# start stab
if cmds.objExists ('stabilizator_expression'):
# stabilizator exists
expression = str (cmds.expression ('stabilizator_expression', string = True, query = True))
camera.shape = expression[2:expression.find('#')]
cmds.delete ('stabilizator_expression')
cmds.select (camera.shape, replace = True)
cmds.warning (('>>> STAB WAS TURNED ON. CHECK: ' + camera.shape + ' <<< FOR NONZERO OFFSET VALUES ::..'))
else:
if cmds.nodeType (point) != 'mesh' and cmds.nodeType (point) != 'transform' and len (point) == 0:
# wrong selection
cmds.warning ('..:: SELECT SOMETHING TO STABILIZE ::..')
else:
point = point[0]
if point != camera.transform and point != camera.shape and camera.transform != 'empty':
# stabilize
cmds.setAttr( camera.shape + '.displayResolution', 0)
cmds.setAttr( camera.shape + '.displayFilmGate', 0)
expression = '//%s#' % camera.shape
expression += '\npython "import maya.cmds as cmds";'
expression += '\npython "fov_h = cmds.camera (\'%s\', query = True, horizontalFieldOfView = True)";' % camera.shape
expression += '\npython "fov_v = cmds.camera (\'%s\', query = True, verticalFieldOfView = True)";' % camera.shape
expression += '\npython "aperture_h = cmds.camera (\'%s\', query = True, horizontalFilmAperture = True)";' % camera.shape
expression += '\npython "aperture_v = cmds.camera (\'%s\', query = True, verticalFilmAperture = True)";' % camera.shape
expression += '\n$pos=`python "fstab.get_normalized_screen_position(\'%s\',\'%s\',fov_h, fov_v,aperture_h,aperture_v)"`;' % (point, camera.transform)
expression += '\nsetAttr "%s.horizontalFilmOffset" ($pos[2]);' % camera.shape
expression += '\nsetAttr "%s.verticalFilmOffset" ($pos[3]);' % camera.shape
# create expression
cmds.expression (name = 'stabilizator_expression', string = expression)
# update GUI
cmds.button ('button_stabilizer',
edit = True,
label ="deStabilize",
backgroundColor = (1, 0, 0),
command = 'fstab.stabilizer("end")')
else:
cmds.warning ('..:: CLICK IN THE PANE WITH THE CAMERA ::..')
示例9: create
def create( self, *args ):
if cmds.window( self.winName, ex=1 ):
cmds.deleteUI( self.winName, wnd=1 )
cmds.window( self.winName, title= self.title, titleBarMenu=0 )
cmds.columnLayout()
cmds.rowColumnLayout( nc=1, cw=[( 1,self.width-2)] )
cmds.text( l='Register ID', h=30 )
idField = cmds.textField( h=25 )
helpField = cmds.textField( en=0 )
cmds.setParent( '..' )
firstWidth = (self.width-2)*0.5
secondWidth = (self.width-2)-firstWidth
cmds.rowColumnLayout( nc=2, cw=[(1,firstWidth),(2,secondWidth)])
cmds.button( l='Create', h=25, c=self.cmdCreate )
cmds.button( l='Cancel', h=25, c=self.cmdCancel )
cmds.setParent( '..' )
cmds.window( self.winName, e=1,
width = self.width,
height = self.height )
cmds.showWindow( self.winName )
self.idField = idField
self.helpField = helpField
示例10: drawButton
def drawButton(self,elem,x,y,w=None,h=None):
""" Draw a Button
@type elem: dictionary
@param elem: the button dictionary
@type x: int
@param x: position on x in the gui windows
@type y: int
@param y: position on y in the gui windows
@type w: int
@param w: force the width of the item
@type h: int
@param h: force the height of the item
"""
name = elem["name"]
if elem["label"] != None:
name = elem["label"]
if elem["action"] is not None :
elem["id"] = cmds.button( label=name,
w=elem["width"]*self.scale,
h=elem["height"]*self.scale,
c=partial(elem["action"],),
recomputeSize=False)
else :
elem["id"] = cmds.button( label=name,
w=elem["width"]*self.scale,
h=elem["height"]*self.scale,recomputeSize=False)
示例11: setupRLUI
def setupRLUI():
if cmds.window("RLWin", exists=True):
cmds.deleteUI("RLWin")
widgets["win"] = cmds.window("RLWin", t="zbw_setupRL", w=200, h=400)
widgets["mainCL"] = cmds.columnLayout(w=200)
widgets["mainFrame"] = cmds.frameLayout(l="Create Render Layers", w=200, cll=True, bgc=(.2,.2,.2))
widgets["CarKey"] = cmds.checkBox(l="Car_Env", v=True)
widgets["CarEnv"] = cmds.checkBox(l="Car_Key", v=True)
widgets["BGKey"] = cmds.checkBox(l="BG_Env", v=True)
widgets["BGEnv"] = cmds.checkBox(l="BG_Key", v=True)
widgets["AO"] = cmds.checkBox(l="All_AO", v=True)
widgets["MatteA"] = cmds.checkBox(l="All_MatteA", v=True)
widgets["MatteB"] = cmds.checkBox(l="All_MatteB", v=True)
widgets["MoVec"] = cmds.checkBox(l="All_MoVec", v=True)
widgets["Shadow"] = cmds.checkBox(l="All_Shadow", v=True)
widgets["createBut"] = cmds.button(l="Create Layers", w=200, h=40, bgc=(.6,.8,.6), c=createRL)
cmds.text("NOTE: this is setting the overrides for \nthe moVec layer RG's and materials \n(if you have them in scene\n for the AO and Movec layers but \n NO passes are set up")
cmds.separator(h=20, style = "double")
#widgets["copyBut"] = cmds.button(l="Copy Selected Layer", w=200, h=40, bgc=(.8,.8,.6), c=copyRL)
#cmds.separator(h=20, style = "double")
widgets["importBut"] = cmds.button(l="Import RL Shaders File", w=200, h=40, bgc=(.8,.6,.6), c=importRL)
cmds.showWindow(widgets["win"])
cmds.window(widgets["win"], e=True, w=200, h=400)
示例12: smoothEdgeLineUI
def smoothEdgeLineUI():
"""
Smooth Edge Line UI
"""
# Window
window = 'smoothEdgesUI'
if cmds.window(window, q=True, ex=1): cmds.deleteUI(window)
window = cmds.window(window, t='Smooth Edge Line', s=True)
# Layout
CL = cmds.columnLayout()
# UI Elements
cmds.intSliderGrp('smoothEdges_smoothISG', label='Smooth', field=True, minValue=1, maxValue=20, fieldMinValue=1,
fieldMaxValue=100, value=4)
cmds.floatSliderGrp('smoothEdges_falloffFSG', label='Falloff Distance', field=True, precision=3, minValue=0.0,
maxValue=10.0, fieldMinValue=0.0, fieldMaxValue=100.0, value=0.01)
cmds.checkBoxGrp('smoothEdges_edgeSpacingCBG', label='Maintain Edge Spacing', numberOfCheckBoxes=1, v1=False)
cmds.checkBoxGrp('smoothEdges_snapToOrigCBG', label='Maintain Shape', numberOfCheckBoxes=1,
v1=False) # columnWidth2=[100,165]
cmds.checkBoxGrp('smoothEdges_deleteHistoryCBG', label='Delete History', numberOfCheckBoxes=1, v1=False)
cmds.button('smoothEdgesB', l='Smooth', w=390, c='glTools.model.straightenVerts.smoothEdgeLineFromUI()')
# Show Window
cmds.window(window, e=True, wh=[392, 115])
cmds.showWindow(window)
示例13: evenEdgeSpacingUI
def evenEdgeSpacingUI():
"""
Even Edge Spacing UI
"""
# Window
window = 'evenEdgeSpacingUI'
if cmds.window(window, q=True, ex=1): cmds.deleteUI(window)
window = cmds.window(window, t='Even Edge Spacing', s=True)
# Layout
CL = cmds.columnLayout()
# UI Elements
cmds.intSliderGrp('evenEdgeSpacing_smoothISG', label='Smooth', field=True, minValue=0, maxValue=20, fieldMinValue=0,
fieldMaxValue=100, value=4)
cmds.floatSliderGrp('evenEdgeSpacing_influenceFSG', label='Influence', field=True, minValue=0.0, maxValue=1.0,
fieldMinValue=0.0, fieldMaxValue=1.0, value=1.0)
cmds.checkBoxGrp('evenEdgeSpacing_snapToOrigCBG', label='Maintain Shape', numberOfCheckBoxes=1,
v1=False) # columnWidth2=[100,165]
cmds.checkBoxGrp('evenEdgeSpacing_deleteHistoryCBG', label='Delete History', numberOfCheckBoxes=1, v1=False)
cmds.button('evenEdgeSpacingB', l='Even Edge Spacing', w=390,
c='glTools.model.straightenVerts.evenEdgeSpacingFromUI()')
# Show Window
cmds.window(window, e=True, wh=[392, 99])
cmds.showWindow(window)
示例14: commonButtons
def commonButtons(self):
# Creates a button size parameter with a padding of 18 pixels. The width is the size of the UI width minus the padding
# divided by three. The height is 26 pixels.
self.commonBtnSize = ((self.size[0]-18)/3, 26)
# Establishes the layout of the buttons. Sets them into a row, with three buttons in the row. Also establishes their size.
# Creates the "create and close" button.
self.actionBtn = mc.button(label = self.actionName, height = self.commonBtnSize[1], command = self.actionBtnCmd)
# Creates the "create" button.
self.createBtn = mc.button(label = "Create", height = self.commonBtnSize[1], command = self.createBtnCmd)
# Creates the "close" button.
self.closeBtn = mc.button(label = "Close", height = self.commonBtnSize[1], command = self.closeBtnCmd)
# Dictates how the buttons scale when the user scales the UI.
# First sets the main form to edit mode.
mc.formLayout(self.mainForm, e=True, attachForm=(
# Then takes each button, specifies the edge to adjust, and then specifies the value to adjust by.
# Pins the action button to the left of the UI with a padding of 5 pixels.
[self.actionBtn, 'left', 5],
# Pins the action button to the bottom of the UI with a padding of 5 pixels.
[self.actionBtn, 'bottom', 5],
# Pins the create button to the bottom of the UI with a padding of 5 pixels.
[self.createBtn, 'bottom', 5],
# Pins the close botton to the bottom of the UI with a padding of 5 pixels.
[self.closeBtn, 'bottom', 5],
# Pins the close button to the right of the UI with a padding of 5 pixels.
[self.closeBtn, 'right', 5]),
# Pins buttons relative to the coordinates specified in the create(self) function according to the
# numberOfDivisions flag in the mainForm command.
attachPosition = ([self.actionBtn, 'right', 1, 33], [self.closeBtn, 'left', 0, 67]),
# Pins the middle button to the outer two buttons. Allows it to scale along with the other two buttons.
attachControl = ([self.createBtn, 'left', 4, self.actionBtn], [self.createBtn, 'right', 4, self.closeBtn]),
# Makes sure that the the top edges of the buttons scale according to the above parameters.
attachNone = ([self.actionBtn, 'top'], [self.createBtn, 'top'], [self.closeBtn, 'top']))
示例15: makeSaveVisible
def makeSaveVisible(self):
cmds.button("btnSaveNetwork", e=1, en = 1)
cmds.button("btnSaveWs", e=1, en = 1)
#if __name__=="__main__":
# obj = shotManager_SID()