maya cmds is not object oriented (as in returning python objects)

self.waveFileAddress = cmds.textField(fileName="", enable=False, width=230)
#returns the name of the ui element as a string

to set its text and get its text you have to query and set it with the
cmds.textField function
cmds.textField(self.waveFileAddress, q=True, text=True)

cmds.textField(self.waveFileAddress, e=True, text=stringConvert)

also it is deprecated, meaning it will be removed in future releases, they
have it around to give people time to update their code before it is
removed. It still functions so old code doesn't break but it will in future
versions


On Tue, Sep 16, 2014 at 9:33 PM, likage <[email protected]> wrote:

> 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
> <https://groups.google.com/d/msgid/python_inside_maya/761b9dea-8314-4da5-84eb-d3c170106aa2%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAM9RXoJfu135zcrtDyeLZA3MT%3Dnk5_T1Zw%2BBymJ-b%3DQb5XY4ow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to