I need help with delete buttons from UI please!

48 views
Skip to first unread message

Vlade Capkun

unread,
Feb 8, 2017, 2:56:36 PM2/8/17
to Python Programming for Autodesk Maya
Here is my code:

import maya.cmds as cmds
from functools import partial

selList = cmds.ls(sl=True)

window = cmds.window( title="Picker", widthHeight=(200, 55) )
lay = cmds.columnLayout( adjustableColumn=True )

cmds.button(label='Add Controls', command='addBtn()')

def doSelect(objSel, *args):
cmds.select(objSel, replace=True)
print objSel
for obj in selList:
cmds.rowLayout(numberOfColumns=3, columnWidth3=(80, 75, 150), adjustableColumn=True, parent=lay)
cmds.button(label=obj, command=partial(doSelect, obj))
cmds.button(label="Remove")
def addBtn():
addSel = cmds.ls(sl=True)
for obj in addSel:
cmds.rowLayout(numberOfColumns=3, columnWidth3=(80, 75, 150), adjustableColumn=True, parent=lay)
cmds.button(label=obj, command=partial(doSelect, obj))
cmds.button(label="Remove")
cmds.showWindow( window )


Justin Israel

unread,
Feb 8, 2017, 3:25:55 PM2/8/17
to Python Programming for Autodesk Maya
You didn't explain your problem. What specifically is your issue?

Justin


--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/42bbf216-e7c5-437c-8e11-64573e449980%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Message has been deleted

Capkun

unread,
Feb 8, 2017, 3:41:47 PM2/8/17
to Python Programming for Autodesk Maya
Thank you for your quick reply Justin Israel and sorry for my english.

I need procedure for  cmds.button(label="Remove")  
i can select objects and add to UI for be selected from there but i don't know how to remove if i don't need more this button for selection.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Justin Israel

unread,
Feb 8, 2017, 3:46:54 PM2/8/17
to Python Programming for Autodesk Maya
If you mean you want to remove the row of buttons when the Remove button is pressed, you could try something like this (untested)

def removeButtons(buttons, *args):
    cmds.deleteUI(*buttons, control=True)

#...
    btn1 = cmds.button(label=obj, command=partial(doSelect, obj))
    btn2 = cmds.button(label="Remove")
    cmds.button(btn2, edit=True, command=partial(removeButtons, [btn1, btn2]))

The return value from each button call gives you the name of the control. Then you can create a callback with the buttons to have them get deleted when it is clicked.

Justin


To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/6caa4333-34c9-45ed-9abe-4a07ced9869c%40googlegroups.com.

Capkun

unread,
Feb 8, 2017, 4:11:06 PM2/8/17
to Python Programming for Autodesk Maya

Yes, now i understand.

Thank you Justin, it works ! 
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.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 python_inside_maya+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages