I believe its a legacy thing from before the UI was written in Qt.
callback(*args) is pretty much just the standard thing I do for any native
maya UI callback, just to absorb the args.
If I am using partial to wrap arguments, it will absorb it at the end:
from functools import partial
cbk = partial(callback, "FOO")
button = cmds.button(c=cbk)
def callback(value, *args):
print value, args
The Maya native UI widgets use the same commands API but they wrap around Qt
widgets under the hood. So at a lower level they are communicating via Qt
signals. But the commands APi still works the same as a layer over the top.
On Jul 15, 2012, at 12:40 PM, Adam Mechtley wrote:
> It's just an argument tuple containing False. I don't have a good "why"
> answer for you, but just change your method parameters for all of your
> Maya-built-in GUI control callbacks to something like this:
>
> def doSomething(self, *args):
>
> On Sun, Jul 15, 2012 at 12:12 PM, Panupat Chongstitwattana
> <[email protected]> wrote:
> I understand completely :)
>
> I've been developing in PyQt too. But I'm hoping to contribute this script on
> cgtalk, so I decided I should use native UI so everyone will be able to open
> it without additional set up.
>
> Thanks Ed.
>
>
> On Sun, Jul 15, 2012 at 11:55 PM, Ed Caspersen <[email protected]> wrote:
> sent too soon, what I meant to say was
>
> ... don't even touch the native UI commands anymore so knowledge on working
> with the native UI commands and widgets in a Python context is quite dated
>
> Ed Caspersen
>
>
>
> On Sun, Jul 15, 2012 at 9:51 AM, Ed Caspersen <[email protected]> wrote:
> It seems so and I am not sure how useful that argument is. Maybe someone else
> has some more insight on why this is. To be honest once AD adapted PyQt I
> switched to developing directly against PyQt and don't even touch the native
> UI commands anymore.
>
> Ed Caspersen
>
>
>
> On Sun, Jul 15, 2012 at 9:47 AM, Panupat Chongstitwattana
> <[email protected]> wrote:
> Thanks Ed.
>
> So Maya's native UI receive signals like PyQt too? Right now I stick a None
> into the argument list and it works. Really curious tho what I can do with it.
>
>
>
> On Sun, Jul 15, 2012 at 11:43 PM, Ed Caspersen <[email protected]> wrote:
> I think the button is emitting a clicked() event that has a bool argument for
> whether or not it is checked.
>
> http://doc.trolltech.com/4.7/qabstractbutton.html#clicked
>
> "Checked" buttons are buttons that stay down after being pressed. Tho I don't
> recall Maya supporting check state buttons but I could be a little dated in
> my knowledge.
>
> Example of checked (or toggle) buttons
> http://zetcode.com/tutorials/pyqt4/widgets/
>
> Ed Caspersen
>
>
> On Sun, Jul 15, 2012 at 9:32 AM, Panupat Chongstitwattana
> <[email protected]> wrote:
> I'm learning how to create python UI. So I made a class with a text field and
> a button.
>
> self.input = cmds.textFieldGrp(label=' label')
> self.submit = cmds.button(label='submit', w=215, command=self.doSomething)
>
> def doSomething(self):
> print "OK"
>
> The button isn't doing anything, but when I clicked it I got this error
>
> TypeError: doSomething() takes exactly 1 argument (2 given) #
>
> Why is the function getting 2 arguments? What is it receiving?
>
>
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>
>
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>
>
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>
>
>
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>
>
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>
>
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings:
http://groups.google.com/group/python_inside_maya/subscribe