本文整理汇总了Python中maya.cmds.textField函数的典型用法代码示例。如果您正苦于以下问题:Python textField函数的具体用法?Python textField怎么用?Python textField使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了textField函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: browseDirectoryPath
def browseDirectoryPath(self, *args):
basicFilter = "*All(*.*);;tif(*.tif);;jpg(*.jpg);;exr(*.exr);;tx(*.tx)"
self.returnPath = cmds.fileDialog2(
fileFilter=basicFilter,
ds=2,
startingDirectory=self.homeDir)[0]
cmds.textField(self.uvImagePath, e=True, text=self.returnPath)
示例2: createAttribute
def createAttribute():
if(not cmds.textField(tf01, text = True, query = True) == ''):
niceName, longName = attrNameDefC()
sel = selectListC()
if(dataTypeC == 'float3'):
for obj in sel:
if(not cmds.attributeQuery(longName, node = obj, exists = True)):
cmds.addAttr(obj, niceName = niceName, longName = longName, usedAsColor = True, attributeType = dataTypeC)
cmds.addAttr(obj, longName = '%sR' % longName, attributeType = 'float', parent = longName)
cmds.addAttr(obj, longName = '%sG' % longName, attributeType = 'float', parent = longName)
cmds.addAttr(obj, longName = '%sB' % longName, attributeType = 'float', parent = longName)
elif(dataTypeC == 'double3'):
for obj in sel:
if(not cmds.attributeQuery(longName, node = obj, exists = True)):
cmds.addAttr(obj, niceName = niceName, longName = longName, attributeType = dataTypeC)
cmds.addAttr(obj, longName = '%sX' % longName, attributeType = 'double', parent = longName)
cmds.addAttr(obj, longName = '%sY' % longName, attributeType = 'double', parent = longName)
cmds.addAttr(obj, longName = '%sZ' % longName, attributeType = 'double', parent = longName)
elif(dataTypeC == 'string'):
for obj in sel:
if(not cmds.attributeQuery(longName, node = obj, exists = True)):
cmds.addAttr(obj, niceName = niceName, longName = longName, dataType = dataTypeC)
else:
for obj in sel:
if(not cmds.attributeQuery(longName, node = obj, exists = True)):
cmds.addAttr(obj, niceName = niceName, longName = longName, attributeType = dataTypeC)
cmds.textField(tf01, text = '', edit = True)
示例3: 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
示例4: loadSurfaceGroup
def loadSurfaceGroup(self, *args ):
sels = cmds.ls( sl=1 )
if not sels: cmds.error( "Select Surface Group" )
children = cmds.listRelatives( sels[-1], c=1, ad=1 )
if not children: cmds.error( "Select Surface Group" )
surfaceGrp = ''
for child in children:
shapes = cmds.listRelatives( child, s=1 )
if not shapes: continue
for shape in shapes:
if cmds.nodeType( shape ) == 'nurbsSurface':
surfaceGrp = sels[-1]
break
if surfaceGrp: break
if not surfaceGrp:
cmds.error( "Select Surface Group" )
cmds.textField( self._surfaceGroup, e=1, tx=surfaceGrp )
if not cmds.attributeQuery( 'sets', node=surfaceGrp, ex=1 ):
fnc.addArrayMessageAttribute( surfaceGrp, 'sets' )
self.saveData()
示例5: loadDirectoryPath
def loadDirectoryPath(textField,caption='Load Directory',startDir=None):
'''
Select a file path to load into a specified textField.
@param textField: TextField UI object to load file path to
@type textField: str
@param caption: File selection UI caption string
@type caption: str
@param startDir: Directory to start browsing from. In None, use the default or last selected directory.
@type startDir: str
'''
# Get File Path
dirPath = mc.fileDialog2( dialogStyle=2,
fileMode=3,
caption=caption,
okCaption='Load',
startingDirectory=startDir )
# Check File Path
if not dirPath:
print('Invalid directory path!')
return
# Load File Path to TextField
if mc.textField(textField,q=True,ex=True):
mc.textField(textField,e=True,text=dirPath[0])
elif mc.textFieldGrp(textField,q=True,ex=True):
mc.textFieldGrp(textField,e=True,text=dirPath[0])
elif mc.textFieldButtonGrp(textField,q=True,ex=True):
mc.textFieldButtonGrp(textField,e=True,text=dirPath[0])
else:
print('UI element "'+textField+'" is of type "'+mc.objectTypeUI(textField)+'"! Expected textField, textFieldGrp or textFieldButtonGrp.')
return
# Return Result
return dirPath[0]
示例6: seqGUI
def seqGUI(parent):
frm = cmds.frameLayout( label="Sequence", cll=True, w=winWidth-5,
collapseCommand=Callback(winExpand, -70),
expandCommand=Callback(winExpand, 70))
frmCol = cmds.columnLayout(rs=3)
cmds.checkBox( "mecRenSeqCB", label="On\Off", v=1)
rowCol = cmds.rowColumnLayout("mecRenSeqRC", nc=2, cw=[[1,winWidth/2],[2,winWidth/2]],
co=[[1,"right",5]])
'''
Older version. Used Callback instead with a function that will enable or disable any gui component.
cmds.checkBox( "mecRenSeqCB", e=True, onc='%s.cmds.rowColumnLayout("mecRenSeqRC", e=True, en=True)' %scriptName)
cmds.checkBox( "mecRenSeqCB", e=True, ofc='%s.cmds.rowColumnLayout("mecRenSeqRC", e=True, en=False)' %scriptName)
'''
cmds.checkBox( "mecRenSeqCB", e=True, onc=Callback(enGUI,"rowColumnLayout", "mecRenSeqRC", 1 ) )
cmds.checkBox( "mecRenSeqCB", e=True, ofc=Callback(enGUI,"rowColumnLayout", "mecRenSeqRC", 0 ))
cmds.textScrollList( "mecRenSeqTSL", h=40, ams=True )
cmds.setParent(rowCol)
subCol = cmds.columnLayout()
rowWidth = winWidth/2
cmds.rowColumnLayout(nc=2, w=rowWidth,
cw=[[1,(rowWidth-70)], [2,60]])
cmds.textField("mecRenSeqName", w=rowWidth-70 )
cmds.button(label="Add",
c=Callback(addTSL, "mecRenSeqTSL"))
cmds.setParent(subCol)
cmds.rowColumnLayout(nc=2, w=rowWidth,
cw=[[1,rowWidth/2],[2,rowWidth/2-10]])
cmds.button(label="Rem All",
c=Callback(remAllTSL, "mecRenSeqTSL"))
cmds.button(label="Rem Sel",
c=Callback(remSelTSL, "mecRenSeqTSL"))
cmds.setParent(parent)
示例7: saveRenameText
def saveRenameText(self):
prefix = cmds.textField( 'prefixTextField', query=True, tx=True )
groupIndex = cmds.textField( 'groupIndexTextField', query=True, tx=True )
body = cmds.textField( 'bodyTextField', query=True, tx=True )
itemIndex = cmds.textField( 'itemIndexTextField', query=True, tx=True )
suffix = cmds.textField( 'suffixTextField', query=True, tx=True )
if prefix in __main__.rroPrefix:
__main__.rroPrefix.remove(prefix)
if groupIndex in __main__.rroGroupIndex:
__main__.rroGroupIndex.remove(groupIndex)
if body in __main__.rroBody:
__main__.rroBody.remove(body)
if itemIndex in __main__.rroItemIndex:
__main__.rroItemIndex.remove(itemIndex)
if suffix in __main__.rroSuffix:
__main__.rroSuffix.remove(suffix)
__main__.rroPrefix.append(prefix)
__main__.rroGroupIndex.append(groupIndex)
__main__.rroBody.append(body)
__main__.rroItemIndex.append(itemIndex)
__main__.rroSuffix.append(suffix)
self.setupPopupMenus()
示例8: renameSelected
def renameSelected(self,*args):
ui.saveRenameText()
self.setInitialGroupIndex()
self.setInitialItemIndex()
itemIndex = self.initialItemIndex
groupIndex = self.initialGroupIndex
switchIndex = cmds.checkBox( 'switchIndexesCheckBox', query=True, v=True )
prefix = cmds.textField( 'prefixTextField', query=True, tx=True )
body = cmds.textField( 'bodyTextField', query=True, tx=True )
suffix = cmds.textField( 'suffixTextField', query=True, tx=True )
groupIndexString = self.getGroupIndex(groupIndex)
#give items a temp name, to help lessen chance of new name already existing
#won't prevent it with items that exist outside of the selection
for index,item in enumerate(cmds.ls( sl=True )):
splitName = item.split('|')[-1]
cmds.rename( item, splitName+'XXX'+str(index) )
for item in cmds.ls( sl=True ):
itemIndexString = self.getItemIndex(itemIndex)
newName = prefix+groupIndexString+body+itemIndexString+suffix
if switchIndex is True:
newName = prefix+itemIndexString+body+groupIndexString+suffix
cmds.rename( item, newName )
itemIndex = itemIndex+1
示例9: create
def create(self):
if cmds.window(self.window, exists=True):
cmds.deleteUI(self.window);
self.window = cmds.loadUI(uiFile=self.uiFile, verbose=False)
cmds.showWindow(self.window);
try:
initPos = cmds.windowPref( self.window, query=True, topLeftCorner=True )
if initPos[0] < 0:
initPos[0] = 0
if initPos[1] < 0:
initPos[1] = 0
cmds.windowPref( self.window, edit=True, topLeftCorner=initPos )
except :
pass
ctrlPath = '|'.join([self.window, 'radioButton']);
cmds.radioButton(ctrlPath, edit=True, select=True);
ctrlPath = '|'.join([self.window, 'groupBox_4']);
cmds.control(ctrlPath, edit=True, enable=False);
ctrlPath = '|'.join([self.window, 'groupBox_2', 'pushButton_7']);
cmds.button(ctrlPath, edit=True, enable=False);
ctrlPath = '|'.join([self.window, 'groupBox_2', 'lineEdit']);
cmds.textField(ctrlPath, edit=True, text="-u --oiio");
示例10: __init__
def __init__(self):
self.name = "rsSubstituteAttribute"
self.title = "rs Substitute Attribute"
i_windowSize = (300, 110)
if (cmds.window(self.name, q=1, exists=1)):
cmds.deleteUI(self.name)
self.window = cmds.window(self.name, title=self.title)
s_winColPro2 = cmds.columnLayout(adjustableColumn=True, parent=self.window)
i_colum3 = (i_windowSize[0] / 6, i_windowSize[0] * 4 / 6, i_windowSize[0] / 6)
s_winRowField1 = cmds.rowLayout(numberOfColumns=3, adjustableColumn3=2, columnWidth3=(i_colum3), columnAlign=(1, 'center'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (3, 'both', 0)], parent=s_winColPro2)
cmds.text(label='Source', align='center', parent=s_winRowField1)
self.sourceText = cmds.textField(cmds.textField(), edit=True, parent=s_winRowField1)
cmds.button(label='Pick up', c=self.rsPickUpSource, parent=s_winRowField1)
s_winRowField2 = cmds.rowLayout(numberOfColumns=3, adjustableColumn3=2, columnWidth3=(i_colum3), columnAlign=(1, 'center'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (3, 'both', 0)], parent=s_winColPro2)
cmds.text(label='Target', align='center', parent=s_winRowField2)
self.targetText = cmds.textField(cmds.textField(), edit=True, parent=s_winRowField2)
cmds.button(label='Pick up', c=self.rsPickUpTarget, parent=s_winRowField2)
cmds.separator(height=5, style="none", hr=True, parent=s_winColPro2)
i_colum = i_windowSize[0] / 3
s_winRow1 = cmds.rowLayout(numberOfColumns=3, adjustableColumn3=2, columnWidth3=(5, i_colum, i_colum), columnAlign=(1, 'center'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (3, 'both', 0)], parent=s_winColPro2)
cmds.separator(height=5, style="none", hr=True, parent=s_winRow1)
self.delAttr = cmds.checkBox("rsDelSourceAttr", label='Delete Source Attribute', align='right', v=True, parent=s_winRow1)
cmds.separator(height=5, style="none", hr=True, parent=s_winColPro2)
self.rsSubs = cmds.button(label='Substitute or Clone', w=100, c=self.rsSubs, parent=s_winColPro2)
cmds.window(self.window, e=1, w=430, h=103)
cmds.showWindow(self.window)
cmds.window(self.window, edit=True, widthHeight=(i_windowSize))
示例11: positionReorderDoIt
def positionReorderDoIt(*args):
meshes = []
sourceMeshText = cmds.textField( 'sourceMeshTextField', query=True, text=True )
if sourceMeshText == '':
cmds.error('source mesh textfield is empty')
if cmds.objExists(sourceMeshText) == False:
cmds.error('the source mesh ( '+sourceMeshText+' ) does not exist')
if cmds.nodeType(sourceMeshText) != 'mesh':
shapes = cmds.listRelatives( sourceMeshText, shapes=True )
if shapes is None or len(shapes) < 1 or cmds.nodeType(shapes[0]) != 'mesh':
cmds.error('source ( '+sourceMeshText+' ) is not a mesh')
meshes.append( sourceMeshText )
destinationMeshText = cmds.textField( 'destinationMeshTextField', query=True, text=True )
if destinationMeshText == '':
cmds.error('destination mesh textfield is empty')
if cmds.objExists(destinationMeshText) == False:
cmds.error('the destination mesh ( '+destinationMeshText+' ) does not exist')
if cmds.nodeType(destinationMeshText) != 'mesh':
shapes = cmds.listRelatives( destinationMeshText, shapes=True )
if shapes is None or len(shapes) < 1 or cmds.nodeType(shapes[0]) != 'mesh':
cmds.error('destination ( '+destinationMeshText+' ) is not a mesh')
meshes.append( destinationMeshText )
positionReorder( meshes=meshes )
示例12: loadInfo
def loadInfo( *args ):
import sgBFunction_fileAndPath
sceneBakeInfoPath = sgBFunction_fileAndPath.getSceneBakeInfoPath()
sgBFunction_fileAndPath.makeFile( WinA_Global.filePathInfo, False )
cmds.textField( WinA_Global.exportPath_txf, e=1, tx= sceneBakeInfoPath )
示例13: createUI
def createUI( pWindowTitle):
windowID = 'myWindowID'
if cmds.window(windowID , exists = True):
cmds.deleteUI(windowID)
cmds.window(windowID , title = pWindowTitle , sizeable = False , resizeToFitChildren = True)
cmds.rowColumnLayout( numberOfColumns = 3 , columnWidth =[(1,200) , (2,200) , (3,200)])
cmds.separator ( h = 30 , style = 'none')
cmds.separator ( h = 30 , style = 'none')
cmds.separator ( h = 30 , style = 'none')
cmds.text(label = 'Enter the path of the code')
cmds.textField('path')
cmds.separator ( h = 30 , style = 'none')
cmds.separator ( h = 30 , style = 'none')
cmds.separator ( h = 30 , style = 'none')
cmds.separator ( h = 30 , style = 'none')
cmds.button(label = 'Generate' , command = generate)
cmds.separator ( h = 30 , style = 'none')
cmds.button(label = 'Build' , command = build)
cmds.separator ( h = 30 , style = 'none')
cmds.separator ( h = 30 , style = 'none')
cmds.separator ( h = 30 , style = 'none')
cmds.showWindow()
示例14: openSelectedCallback
def openSelectedCallback(self,*args):
"""
This method is called on double click selected item in textscrollList
"""
#try block also saves from error caused by directories that we do not have rights to access.
cMsg="Selected scene file is already open. Do you want to reload it?\n If you reload all changes you made since last save will be lost."
try:
cmds.button('upBtn',edit=True,enable=True)
self.selectedItem=str(os.path.join(cmds.textField('location',q=True,tx=True),str(cmds.textScrollList('fileLister',q=True,si=True)[0]).split(" > ")[0])).replace("/","\\")
if (self.selectedItem.endswith("ma")) or (self.selectedItem.endswith("mb")):
print "selected Item: %s\n scene Open: %s"%(self.selectedItem , cmds.file(q=True,sn=True))
if self.selectedItem==cmds.file(q=True,sn=True).replace("/","\\"):
print "Same Scene"
result=cmds.confirmDialog(t='Warning',m=cMsg,button=['Yes','No'], defaultButton='Yes', cancelButton='No', dismissString='No' )
if result== "Yes":
state= cmds.file(self.selectedItem,open=True, f=True)
else:
print"Saved scene file %s"%os.path.basename(cmds.file(q=True,sn=True))
## if not cmds.file(q=True,save=True):
## cmds.file(save=True)
state= cmds.file(self.selectedItem,open=True, f=True)
else:
if os.path.isdir(self.selectedItem):
cmds.textField('location',edit=True,tx=self.selectedItem)
self.populatescrollList(self.selectedItem.replace("/","\\"))
except Exception as e:
print e
示例15: searchReplaceSelectedChains
def searchReplaceSelectedChains(self,*args):
ui.saveSearchReplaceText()
self.search = cmds.textField( 'searchTextField', query=True, tx=True )
self.replace = cmds.textField( 'replaceTextField', query=True, tx=True )
for index,parentJoint in enumerate( cmds.ls( sl=True ) ):
self.searchReplaceChain( parentJoint )