Reputation: 2441
Maya cmds: I have a basic grid and I want to remove an item, but the grid doesn't update. So the removed item keeps taking up space. How can I make the gridLayout refresh or re-align its items?
import maya.cmds as cmds
def change(*args):
cmds.iconTextCheckBox('two', edit=True, visible=False)
window = cmds.window()
cmds.gridLayout()
cmds.iconTextCheckBox('one', style='textOnly', label='item')
cmds.iconTextCheckBox('two', style='textOnly', label='item')
cmds.iconTextCheckBox('three', style='textOnly', label='item')
cmds.button(label='GO', command=change)
cmds.showWindow(window)
Upvotes: 2
Views: 362
Reputation: 58563
Executing your code you don't delete the second element, you're just turning its visibility off.
To check this statement, execute the following line of code and you'll turn a visibility on:
cmds.iconTextCheckBox('two', edit=True, visible=True)
You need to use QT's QGridLayout() class (not Maya's cmds).
To remove a widget from a layout, call removeWidget()
method.
Upvotes: 1