PyMEL: workspaceControl -crashes app when uiScript -flag isn't precisely a function


#1

I have an issue with a workspaceControl causing Maya to crash due to faulty data on the uiScript -flag.
Docs say that the data has to be a script. Problem is that I cannot hardcode the function call as there are conditionals prior to the control that will decide what function should be called by the workspaceControl.

I tried using functools.partial() but it still crashes. Pseudo-code:

import pymel.core as pm
from functools import partial

def someFunc(someVar, *args):
    # UI-building code

if something == "A":
    myScriptVar = partial(someFunc, varA)
else:
    myScriptVar = partial(someFunc, varB)

pm.workspaceControl(
    uiScript=myScriptVar
)




Why does this fail?
(also tried assigning a lambda function to myScriptVar and it gives me the same kind of crash)


#2

Why don’t you just call a function and pass in the args and let that function do the conditional decision making and launch other functions etc? Or are you saying that it is patial (or lambda) that are causing the crash?

David