Search code examples
pythonmaya

Maya workspaceControl 'uiScript' does not update to new function


I am creating a new workspaceControl inside maya 2018.6.

When I change the uiScript flag to point to a new function and re launch the workspaceControl it is still calling the old function. Here is a simple version of my code:

dockName = 'myNewDock'
def test1():
    print 'test 1'
def test2():
    print 'test 2'    
cmds.workspaceControl(dockName, retain=False, floating=True, l='My Dock Test', uiScript="test1()")

The above works fine. However, when I change:

uiScript="test1()"

To be:

uiScript="test2()"

It still prints out

test 1

I have tried closing the workspaceControl manually. I have also tried using various combinations of the following code:

cmds.deleteUI(dockName)
cmds.workspaceControl(dockName, edit=True, close=True)

Even closing Maya and re launching it does not solve the issue, it still calls test1()

It will only update if I change the 'dockName'. This tells me that Maya is storing the UIScript somewhere internally, I have been all through my preferences and can not find reference to it anywhere. Does anyone have any idea how to solve this issue without constantly renaming the dock every time I want to try something different?

Thanks


Solution

  • I've never used this command and I don't have maya for few weeks. Note that command flag is not meant to have string :

    mywcctrl = cmds.workspaceControl(dockName, retain=False, floating=True, l='My Dock Test', uiScript=test1)
    

    you should be able to modify it with :

    cmds.workspaceControl(mywcctrl , edit = True, uiScript=test2)
    

    otherwise, in maya pref, it saves your scene file with layout pref, window, and few other things, so if you close maya and re-open it might cause problems :

    Window > Settings/Preferences > Preferences > UI Elements
    

    enter image description here