Hi Jessica,
The fileBrowserDialog is deprecated according to the documentation, however it still shows an example using the fileCommand callback http://download.autodesk.com/global/docs/maya2012/en\_us/CommandsPython/fileBrowserDialog.html
It also shows you the recommended way of doing things.
import maya.cmds as cmds
# Old way:
def importImage( fileName, fileType):
cmds.file( fileName, i=True );
return 1
cmds.fileBrowserDialog( m=0, fc=importImage, ft='image', an='Import_Image', om='Import' )
# Recommended way:
filename = cmds.fileDialog2(fileMode=1, caption="Import Image")
cmds.file( filename[0], i=True );
It is not really neccesary to use callbacks since the code will pause while choosing a directory. When it continues you can check the input and call the needed functions.
So to fix your code above:
import maya.cmds as cmds
#
#old way:
#
def browseForFolderCallback(mayaFolder, fileType = None):
# fileType is None because we won't be needing it anyway and is there for compatibility
print "Folder selected is: %s" % str(mayaFolder)
def browseFolder(startFolder):
mayaFolder = cmds.workspace( q=True, dir=True )
cmds.workspace (dir=startFolder)
cmds.fileBrowserDialog(mode=4, fileCommand=browseForFolderCallback, actionName = "Pick your folder")
browseFolder("C:/")
#
#new way:
#
def browseFolder2(startFolder):
mayaFolder = cmds.workspace(q=True, dir=True)
cmds.workspace (dir=startFolder)
mayaFolder = cmds.fileDialog2(fm=3, caption = "Pick your folder")
# When you press cancel or close, mayaFolder would be None and not running this code.
if mayaFolder:
browseForFolderCallback(mayaFolder[0])
browseFolder2("C:/")