Also do you know why you have to include the *args?
you dont have to but the signature must match what maya pushes and maya items may push more then readily apparent at first. makig *args makes pyhon agnostic to whatever signature of unnamed variables passed as it accepts them all. In fact you can add *args,**dict to your calls and ANY signature will be accepted.
you dont need args it works if you do:
def someDef(self, boolean):
text = cmds.textField(self.text, tx=True, q=True)
print text
Se the point is the button actually calls someDef(False) which is not your signature if you dont have the second parameter
PS: dont make the window unique by design, make it possible to open several windows. eg:
class Window(object):
def __init__(self):
self.Win = ''
self.text = ''
self.wind()
def wind(self):
self.Win = cmds.window()
cmds.rowColumnLayout( numberOfColumns=2, columnWidth=[ (1, 250), (2,250) ])
self.text = cmds.textField( )
cmds.button(l="Print Text",ann="foo" , c=self.someDef)
cmds.showWindow()
def someDef(self, *args):
text = cmds.textField(self.text, tx=True, q=True)
print text
But in reality you really want to make a panel not window 99% of the time but then you can not really use python*. Crap isnt it. Panels are much better in terms of usability as they are persitent and propagate hotkeys right. They can also be reinstantiated by the user to given state later
- the reason for this is that panels save with files so they need to be mel inorder to be able to save