Hi,

What problem are you trying to solve, exactly? The reason I ask is because
there are multiple ways to answer this question depending on what your goal
is, and whether this is just a trivial example of testing out UI, or if you
actually have a use case.

Here are two examples:

import maya.cmds as mc def create_button(*args): mc.setParent('ABC') name =
mc.button(label='newButton') # Do something with button name print name
mc.window('ss') mc.frameLayout ('ABC') mc.button(label='create1', command=
"mc.setParent('ABC');mc.button(label='newButton')") mc.button(label=
'create2', command=create_button) mc.showWindow('ss') # Get the last button
that was created in the layout lastButton = mc.layout('ABC', q=True,
childArray=True)[-1]

You can query for the last button that was created, by asking the layout.
But it would seem the more useful approach is to not use string commands,
but rather a callable. This callable will give you more control over
creating the button by actually being able to save the name of the button
and do something with it.



On Mon Nov 17 2014 at 6:50:17 PM maya2000 <[email protected]> wrote:

> hi....
> after running this cide:
> #...create new button Window:
> mc.window('ss')
> mc.frameLayout ('ABC')
> mc.button(label='createNewButton', command="mc.setParent('ABC');
> mc.button(label='newButton')")
> mc.showWindow('ss')
> #end.....
> when press "createNewButton" button,maya in the "ABC" frameLayout craete a
> new button....now how query new button name, when press it?
> sorry...my english is bad!....
>
> --
> 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 view this discussion on the web visit https://groups.google.com/d/
> msgid/python_inside_maya/66259fd7-ea88-481a-a6ef-
> 0779a7c2f560%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/66259fd7-ea88-481a-a6ef-0779a7c2f560%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA16ZjbM_3-6HoKRzFanX9XdYSgVLKQ1N4Bmg%3DryYHYyWw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to