Pyside with UI file > Make dockable


I’ve been playing with the Qt designer generated UI file and it worked really well following this post

And now I am trying make it dock-able following this guide from Autodesk

But I can’t get it to work together. Any idea how to make Tim’s script dockable?

Any help would be very much appreciated!


This has been my workflow for creating UI’s dockable using a UI file.

        Now I've done away with the whole loading the UI dynamically with QUiLoader() and here's why. I prefer to convert the UI file into a py file with pyside-uic and then load the UI class object into my UI code. This allows me to directly access all the UI objects in my code.
        To do this I open up a cmd prompt and navigate to the folder that has the .ui file. Then I'll run for example:
pyside-uic myTool.ui -o
        Then in my import declarations I'll import the UI class.
from myTool_ui import Ui_myTool
  • My formatting may be off a bit so you’ll have to tweak it if you copy and paste.
    For the dockable stuff you import this:
from import MayaQWidgetDockableMixin
       This would be my boiler-plate UI class: 
from shiboken import wrapInstance
    from PySide import QtGui, QtCore
    import maya.OpenMayaUI as OpenMayaUI
    from import MayaQWidgetDockableMixin
    def getMayaWindow():
    	Get Maya window
    	:return: maya wnd
    	mayaMainWindowPtr = OpenMayaUI.MQtUtil.mainWindow()
    	return wrapInstance(long(mayaMainWindowPtr), QtGui.QWidget)
    class MayaDockUI(MayaQWidgetDockableMixin, QtGui.QDialog):
    	def __init__(self, parent=getMayaWindow(), *args, **kwargs):
    		super(MayaDockUI, self).__init__(parent=parent, *args, **kwargs)
    	def dockCloseEventTriggered(self):
    		Handle stuff when the dock is closed
       Then I'd import this class as well as my converted UI class into my tool class:
from mayaDockUI import MayaDockUI
  from myTool_ui import Ui_myTool
           class MySimpleWindow(MayaDockUI, UI_myTool):
           	def __init__(self, parent=None):
           		super(MySimpleWindow, self).__init__(parent=parent)
       Then in my main() function I set the docking up:
def main():
           	global dialog 
           	dialog  = MySimpleWindow()
           	dialog.setDockableParameters(dockable=True, floating=True, area='right', allowedArea='right')
           	# Make sure the docked UI pops up to the front

Hope that’s clear and helps.



Wow! Thank you so much for taking the time to reply. I haven’t tried this yet but learning so much already. Thank you so much once again!!! NowI can’t wait to go home and try this.


Sure thing. :thumbsup:



Can I ask for a complete example with files if it is not too much?



Thank you so much !
(4y later but still)