This code example looks like if the window exists, you delete it and then
don't initialize a new one.

Also I would recommend not using a constant for the window name, and
instead saving the last window name returned from cmds.window as an
instance attribute. That way you can always be sure you are deleting the
last window you actually created, even if there was a name clash producing
a different name, or Maya decided to rename it. I haven't tested your code,
but are you sure Maya isnt replacing that illegal space character in the
window name? This would be an ideal reason to save the returned window
name, and reuse that on subsequent calls
 On 17/09/2014 6:22 PM, "likage" <[email protected]> wrote:

> I have this problem, in which I am trying to check if this particular
> exists, it will delete the current ui and re-generates a new ui of the same
> application.
> So basically what happens here is that when user imports in a particular
> format, this ui will then pops up.
>
> So supposedly if the user import in again while the ui is still opened, it
> will simply kills off the former window and 'reboot' it again.
> Thus it keeps printing out "no existence window"
>
> However, as I tried to execute it, it seems to be unable to read the
> existence of the window, and as a result I have 2 windows instead.
> Adding on, this script is part of a plugin execution but I do not think so
> it affects the window naming, i guess.
>
> Any ideas?
>
>
> win_name = "Import chan"
> ...
> ...
> class CustomNodeTranslator(OpenMayaMPx.MPxFileTranslator):
>     def reader(self, fileObject, optionString, accessMode):
>         if cmds.window(win_name, exists = True):
>             cmds.deleteUI(win_name)
>             print "The application is already opened!"
>         else:
>             print "no existence window"
>             self.initialWindow()
>         ...
>         ...
>
>     def initialWindow(self, *args):
>         self.window = cmds.window(title="Import chan", menuBar=True,
> iconName='.chanFileImport', widthHeight=(335, 221), sizeable=False)
>         ...
>         ...
>
>
>  --
> 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/8274b1fe-3962-496e-ad9f-33548d835861%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/8274b1fe-3962-496e-ad9f-33548d835861%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/CAPGFgA2%3Doi2%3Ds2yE06rE34xY3_MG-N0iEQCSBCPCgZK%2BhT%2BPxg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to