Maya 2011 adds PyQt bindings and dockControl command
…and this enables the docking of any custom window you create to the main maya interface. The UI can then be moved docked and undocked from anywhere TO anywhere. I immediately have embraced this godsend to the hellish Maya UI coding world. This isn’t really new news since Maya 2011 has been around for a little while now but I wanted to quickly share my code for making windows dockable. I have expanded my floating tools shelf to have a button that makes the UI dockable when you press it. The old window gets created in my userSetup and is not dockable until now that I added this command as a button to it.
The command gets called only when pressing the button and the command also stores the UI object’s names and specifics so that I can use it to modularly make more buttons on other UIs so that they can also be dockable. The whole key is being modular and not storing global variables which I consider messy.
If you’re gonna make a proc, that is easy
//Given a window name, a name to call the control, and placement in the main maya window,
//add the ability to dock the UI to the main maya UI.
global proc string jaDockUiCommand (string $winName, string $ctrlName, string $placement) {
global string $gMainWindow;
string $userPrefs = `internalVar -upd`;
string $mayaVersion;
string $buffer[];
int $numTokens = `tokenize $userPrefs "/" $buffer`;
$mayaVersion = `substring $buffer[5] 0 4`;
if ($mayaVersion == "2011")
{
string $layout1 = `paneLayout -configuration "single" -parent $gMainWindow`;
string $myDC = `dockControl
-allowedArea "all"
-area $placement
-content $layout1
-label $ctrlName`
;
control -e -p $layout1 $winName;
return 1;
}
return 0;
}
Read more
Lead By Following!