IconTextButton maya python query

153 views
Skip to first unread message

Nitin Singh

unread,
Jul 6, 2017, 11:16:47 AM7/6/17
to Python Programming for Autodesk Maya
Hello Guys,

I have a quick question, I am populating UI with bunch of images using a for loop. When I query the lable it gives me the name for the last image. I can't seem to find a way to query the info on any other selected image. I understand the reason why I am getting the last for loop entry but what would be the correct way of doing it. 
here is the piece of code I am using.

any help will be awesome.

########################################################################

def click(*args):
    ans =  cmds.iconTextButton(btnIcn, label =True, q = True)
    print (ans)
   

window = cmds.window(title='imageTextButtonTest')
layout = cmds.columnLayout()
for i in range(4):
    btn = ('icon_' + str(i))
    btnIcn = cmds.iconTextButton(label = btn, style='iconAndTextVertical',c = click, image=r'C:\Users\nitin\Desktop\icon\201577.png',sic = True, h=150,w=150)

cmds.showWindow(window)

########################################################################




Han Jiang

unread,
Jul 6, 2017, 12:19:51 PM7/6/17
to python_in...@googlegroups.com
You can use functools.partial to pass your label directly, no need to query. Then btn( the label) will be in args tuple.

c = partial(click, btn)

--
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 python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/ed75dad1-6bbb-4a6b-a967-64a179a87ffa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nitin Singh

unread,
Jul 7, 2017, 10:50:49 AM7/7/17
to Python Programming for Autodesk Maya

Thanks a lot for quick reply. :) IT worked
Reply all
Reply to author
Forward
0 new messages