Maya Python - workspaceControl - Can't get the UI contents to appear in the widget after I relaunch Maya

Maya Python - workspaceControl - Can't get the UI contents to appear in the widget after I relaunch Maya

petarpehchevski3d
Explorer Explorer
808 Views
2 Replies
Message 1 of 3

Maya Python - workspaceControl - Can't get the UI contents to appear in the widget after I relaunch Maya

petarpehchevski3d
Explorer
Explorer

Hello. When using the cmds.workspaceControl to make your script UIs dockable, after I relaunch Maya the workspaceControl widget stays in the same space where I docked it, but the contents within it are missing. How do I get my UI to appear? I've tried multiple ways to call upon it but I'm kinda stuck.  

 

I've attached 2 images, one of the start of the code, another from the end. 

Accepted solutions (1)
809 Views
2 Replies
Replies (2)
Message 2 of 3

Kahylan
Advisor
Advisor
Accepted solution

Hi!

 

Thats because your function "dockingTest" gets erased from the working memory when you restart maya. But this can be easily solved by loading your UI as an external module.

 

copy your code except for the last line into another scripteditor tab and then save it into a file that is in your pythonpath (for example your scripts folder) and call that file "dockingUI.py".

 

Then you call your workspaceControl as follows:

 

import maya.cmds as cmds
import maya.mel as mel 
cmds.workspaceControl("Aang", floating=False, retain = False, uiScript= "import maya.cmds as cmds;"
                                "import dockingUI as dUI;"
                                "dUI.dockingTest();")

 

This way your workspaceControl loads the UI in from the external file instead of looking for the function "dockingTest" in the working memory.

 

I hope it helps!

Message 3 of 3

petarpehchevski3d
Explorer
Explorer
Thank you so much for the response, that solved the problem!