Some time ago I created a simple Toolbox using PySide and a dockControl for it so it would live with the Attribute Editor and Channel Box.
Every once in awhile an artist will hit some errors trying to open the UI and I am trying to track down what is causing the failure (the UI will open correctly on a second attempt).
Here are the types of errors that I am getting and my suspicion is aimed at how I manage the dockControl (otherwise, multiple copies of the window will keep docking themselves).
RuntimeError: Controls must have a layout. No layout found in window :
This occurs on the line creating the dockControl and assigning the UI as the contents.
RuntimeError: Object's window not found.
This occurs on the line setting the widget for a QScrollArea
I create the UI using a common pattern to ensure only one instance of the UI is open:
def openGUI():
global toolbox
try:
toolbox.close()
toolbox.deleteLater()
except: pass
toolbox = MyToolbox()
Inside the init method, I create the dockControl. I re-implemented the close method to delete the dockControl.
def __init__(self, parent=getMayaMainWindow()):
# usual stuff
self.dockCtrl = cmds.dockControl(aa=['right', 'left'], a='right',
content=self.objectName(), w=370,
label='My Tool Box')
def closeEvent(self, event):
cmds.deleteUI(self.dockCtrl)
QtGui.QWidget.closeEvent(self, event)
I feel like I am doing something wrong with managing the visibility of the UI and the dockControl, a chicken-and-the-egg type of scenario.
Any advice?
Thanks.