tech maya python brotools

Maya - new approach to dockable windows

2018-02-14

Maya 2017 brought us new interface, new features and... new problems in form of API changes. First thing we faced was switch from PySide to PySide2. But that could be easily solved with simple import trick:

try:
    from PySide2.QtGui import *
    from PySide2.QtCore import *
    from PySide2.QtWidgets import *
    from shiboken2 import wrapInstance

    print "Using PySide2"

except:
    from PySide.QtGui import *
    from PySide.QtCore import *
    from shiboken import wrapInstance

    print "Using PySide"

Or by using great Qt.py module: https://github.com/mottosso/Qt.py by Marcus Ottosson

But, as it turns out, this was not all. Maya now uses workspaceControl instead of dockControl . Well, not instead, but in addition to. But dockControl now just looks ugly, because it only supports docking to the far-right and far-left, where's there are no much more dockable regions in maya. Basically, you can't dock it next to Attribute editor anymore, only workspaceControl can do that.

Another problem was that workspaceControl is QWidget and I could not just add QMainWindow to it, so I could not use setMenuBar or setStatusBar commands.

I spent some time trying to come up with a solution, and so far this is what I've got. It is still work in progress, but it works! With custom menubar and statusbar functions.

https://gist.github.com/Nixellion/1aa5acf900e5ddf1a913a6edf5ac3e16

Feel free to join the discussion.

Or write comments right here.

Maya 2016

Maya 2017