I am trying to make the switch from MEL to python. I am trying to build a simple UI for one of my scripts and I am having some trouble.
import maya.cmds as m
from functools import partial
def createCtrl():
print "hello world"
class ui():
def __init__(self, winName="ctrlLibWin"):
self.winTitle = "Controller Library"
self.winName = winName
def create(self):
if m.window(self.winName, exists=True):
m.deleteUI(self.winName)
m.window(self.winName, title=self.winTitle)
self.mainCol = m.columnLayout()
self.btnA = m.button(l = "Create Controller", c = partial(createCtrl, self))
self.rBox = m.checkBox(l = "Red", v = 1, onc = self.rOn)
self.gBox = m.checkBox(l = "Green", v = 0, onc = self.gOn)
self.bBox = m.checkBox(l = "Blue", v = 0, onc = self.bOn)
self.yBox = m.checkBox(l = "Yellow", v = 0, onc = self.yOn)
m.showWindow( self.winName )
m.window(self.winName)
def rOn(self):
print "hi"
#m.checkBox(self.gBox, v= 0, e=True)
#self.gBox = m.checkBox(e=True, v = 0)
#ui.create.bBox(e=True, v=0)
#ui.create.yBox(e=True, v=0)
def gOn(self):
print "hello"
#ui.create.yBox(e=True, v=0)
#ui.create.bBox(e=True, v=0)
#ui.create.rBox(e=True, v=0)
def bOn(self):
print "hello"
#ui.create.gBox(e=True, v=0)
#ui.create.yBox(e=True, v=0)
#ui.create.rBox(e=True, v=0)
def yOn(self):
print "hello"
#ui.create.gBox(e=True, v=0)
#ui.create.bBox(e=True, v=0)
#ui.create.rBox(e=True, v=0)
inst = ui()
inst.create()
When I run the script and toggle the "Red" checkbox, i get the following error:
# Error: rOn() takes exactly 1 argument (2 given) #
I am not giving the rOn() method any arguments as far as I can tell.
I am also getting the error:
# Error: RuntimeError: file <maya console> line 26: Object's name 'ctrlLibWin' is not unique. #
The script deletes the window if there is already one active, so I don't think I should be getting that error?
Any assistance would be appreciated.