- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've been trying to adapt the example code in the workspaceControl documentation into a class and haven't been able to do it. Here is the documentation code:
import maya.cmds as cmds def createCustomWorkspaceControlUI(*args): cmds.columnLayout() cmds.button() cmds.button() cmds.button() cmds.workspaceControl("myCustomWorkspaceControl", retain=False, floating=True, uiScript="createCustomWorkspaceControlUI()");
And here is a simplification of how I adapted it:
import maya.cmds as cmds class ui(object): def build(self): if cmds.workspaceControl("myCustomWorkspaceControl", exists=1): cmds.deleteUI("myCustomWorkspaceControl") self.wS = cmds.workspaceControl("myCustomWorkspaceControl", retain=False, floating=True, uiScript="createCustomWorkspaceControlUI"); def createCustomWorkspaceControlUI(self, *args): print("1") o = ui() o.build()
When I execute the previous code I get the following error:
# Error: line 1: NameError: file <maya console> line 1: name 'createCustomWorkspaceControlUI' is not defined #
On the other hand, if you execute inside of Maya
def createCustomWorkspaceControlUI(self, *args): print("1")
and then execute my adapted code it will work. The documentation and errors I've been getting tell me that uiScript only accepts two kinds of input: strings and functions. I believe that methods inside a class are not accepted by the uiScript as they are technically not the same as functions. Am I wrong? Is my only solution to turn the whole ui creation into a function not part of my UI class?
Thank you in advance
Solved! Go to Solution.