Deleting UI elements

UI Elements are deleted using the deleteUI command or when their parent is deleted. For example, executing the command after running Script 4 above will delete the column layout TestColumnLayout and its button children.

deleteUI ExampleWindow4|TestFrameLayout|TestColumnLayout;

To avoid a build up of user created UI elements the default behavior for windows is that they and their contents are deleted when they are closed. Therefore closing a window with the Motif window menu or the -visible false flag will delete the window and its contents. A window can be made persistent when it is not visible by using the -retain flag on creation.

Important: If the callback for a field in a window issues a deleteUI command for the window it is in, then Maya will suffer a fatal error. For example:
window w; columnLayout; textField -cc "deleteUI w"; showWindow w;
To avoid the fatal error, use the evalDeferred command. So in the previous example, change the textField command to:
textField -cc "evalDeferred(\"deleteUI w\")";