UI Window not reopening when I rerun script

141 views
Skip to first unread message

eunice...@gmail.com

unread,
Jun 30, 2017, 5:42:01 AM6/30/17
to Python Programming for Autodesk Maya
Hi

I am having some problems here. I made a Maya UI window with QtDesigner and I'm trying to get it to dock at the side. Everytime I run the script, it will appear. However, once I close the UI window and rerun the script, the window will not appear again. I am thinking maybe I need to reinitialise the script but I'm not sure about that. Any advice on how to fix this? Here is my code.

def getMayaWindow():
ptr = apiUI.MQtUtil.mainWindow()
if ptr is not None:
return shiboken.wrapInstance(long(ptr), QtGui.QMainWindow)

class pipeWindow(formClass,baseClass):

def __init__(self, parent=getMayaWindow()):
super(pipeWindow,self).__init__(parent)

self.setupUi(self)
self.setObjectName('pipe_window')

self.project = ""

try:
cmds.deleteUI('dockPane')
except:
pass

self.pane = cmds.paneLayout('dockPane', cn='single')

if 'pipeDock' not in cmds.lsUI(ctl=1) :
cmds.dockControl('pipeDock', con=self.pane, area='right', allowedArea = ['right','left'], label = "ANMD_Pipeline", w=365)
else:
pass
cmds.control( 'pipe_window', e=True, p=self.pane)

Eunice

Justin Israel

unread,
Jun 30, 2017, 10:19:03 PM6/30/17
to python_in...@googlegroups.com
Hi,

What it looks like is that you are doing this check:

    if 'pipeDock' not in cmds.lsUI(ctl=1) :

And you only create the dock if it doesn't exist. But, closing it doesn't necessary mean it is deleted. So you have a hidden dock still in Maya. Now you end up just creating more widgets with no dock that aren't shown. Try adding something like this:

...
        # I needed to add this for subsequent launches to make sure 
        # the initial parent is set
        cmds.setParent(self.parentWidget().objectName())

        self.pane = cmds.paneLayout('dockPane', cn='single')

        
if 'pipeDock' not in cmds.lsUI(ctl=1) :
            cmds.dockControl('pipeDock', con=self.pane, 
                area='right', allowedArea = ['right','left'], 
                label = "ANMD_Pipeline", w=365
)

        # No matter what, make sure we make the dock visible
        cmds.dockControl('pipeDock', e=True, vis=True)

...

Does that help?

--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/45b5e20e-27c5-412d-9805-d9da488df7ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages