I tried replacing the filwBrowserDialog with fileDialog2 but I met with 
some errors, especially so when I try adding in the file path

Basically what the following code does is that it will browse for this obj 
file, and once the user has selected, it will insert the file path (full 
path btw) into the self.waveFileAddress.
However, when the browser is open, there are some warnings logs prompted:
# Warning: Command fileBrowserDialog has been deprecated. Use fileDialog2 
instead. #
# Warning: Flag -operationMode is obsolete. #

This is the original code:
def initialWindow(self, *args):
    ...
    ...
    self.waveFileAddress = cmds.textField(fileName="", enable=False, width=
230)
    self.browseForObj = cmds.symbolButton(image="navButtonBrowse.xpm", 
command=self.getObjFile, enable=False)

def getObjFile(self, *args):
    cmds.fileBrowserDialog( mode=0, fileCommand=self.importImage, fileType=
'OBJ', actionName='Import', operationMode='Import' )   
    
def importImage(self, fileName, fileType):
    cmds.textField(self.waveFileAddress, edit=True, text=fileName)
    return 1


And so, I tried it out using fileDialog2 and I took out the importImage 
function as well, thus the code now becomes like this:
def initialWindow(self, *args):
    ...
    ...
    self.waveFileAddress = cmds.textField(fileName="", enable=False, width=
230)
    self.browseForObj = cmds.symbolButton(image="navButtonBrowse.xpm", 
command=self.getObjFile, enable=False)

def getObjFile(self, *args):    objFilter = "OBJ (*.obj)"
    fileList = cmds.fileDialog2(fileMode=1, fileFilter=objFilter, 
dialogStyle=2)
    stringConvert = ''.join(fileList)
    stringConvert = self.waveFileAddress

However, I got the following error instead;
#     self.waveFileAddress.setText(stringConvert)
# AttributeError: 'unicode' object has no attribute 'setText' # 

So how can I insert the file path into this text field? Please do note that 
the UI is created using the maya UI commands.
Also, one more question would be if fileBrowserDialog is deprecated, why is 
it that I can still use it?

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/761b9dea-8314-4da5-84eb-d3c170106aa2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to