If you look at the `button` documentation you will notice that they are using *args in the function argument.
import maya.cmds as cmds def defaultButtonPush(**args*): print args cmds.window( width=150 ) cmds.columnLayout( adjustableColumn=True ) btn = cmds.button( label='Button 1', command=defaultButtonPush ) cmds.showWindow() Click the button and you should see (False,) printed in the shell. PyQt emits a boolean for the checked state when the button is clicked. As far as I know Maya did not implement this state feature into the button widget (tho it should work if you are actually building a PyQt gui via the PyQt api) http://qt-project.org/doc/qt-4.8/qabstractbutton.html#clicked You either have to add (self, *args) , (self, arg=False), or (self, arg). The first 2 would at least allow your method to be called from elsewhere without having to think about satisfying arguments. Ed Caspersen On Sat, May 4, 2013 at 4:42 PM, Todd Widup <[email protected]> wrote: > hey Justin, now I get this : > > # Error: myfunction() takes exactly 1 argument (2 given) > > # TypeError: myfunction() takes exactly 1 argument (2 given) # > > > > but I am not passing it any arguments. > > > > this is exactly what I have > > > > cmds.button(proc, e = 1, command = self.myfunction) > > > > > > def myfunction(self): > > blah...... > > > > > > > On Sat, May 4, 2013 at 4:03 PM, Todd Widup <[email protected]> wrote: > >> ah ok, thanks Justin >> >> >> On Sat, May 4, 2013 at 3:56 PM, Justin Israel <[email protected]>wrote: >> >>> Make sure you are passing the method object and not actually calling it: >>> >>> cmds.button(myButton, e = 1, command = self.process) >>> >>> You were doing this: self.process() >>> >>> >>> >>> On May 5, 2013, at 10:54 AM, Todd Widup wrote: >>> >>> using the CMDS commands for a quick UI >>> >>> when I have this in my code : >>> >>> cmds.button(myButton, e = 1, command = self.process()) >>> >>> it is running it as soon as the window is built. any suggestions on how >>> to prevent it from running at once? >>> >>> -- >>> Todd Widup >>> Creature TD / Technical Artist >>> [email protected] >>> [email protected] >>> www.toddwidup.com >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Python Programming for Autodesk Maya" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To post to this group, send email to [email protected] >>> . >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Python Programming for Autodesk Maya" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To post to this group, send email to [email protected] >>> . >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> >> >> -- >> Todd Widup >> Creature TD / Technical Artist >> [email protected] >> [email protected] >> www.toddwidup.com >> > > > > -- > Todd Widup > Creature TD / Technical Artist > [email protected] > [email protected] > www.toddwidup.com > > -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
