You can have have an add button to add frames, and then have each frame contain its own remove button.
// make a unique window containing a form that contains a button to add new frames,
// and a columnLayout to contain the frames.
// The columnLayout is contained in a scrollLayout to handle overflow.
// the button is declared after the columnLayout because it has to pass the
// columnLayout name to the addAFrame procedure
global proc addRemoveFrames() {
if (`window -q -exists addRemoveFramesWindow`) deleteUI addRemoveFramesWindow;
string $win = `window -wh 200 600 -t ("Add & Remove Frames") addRemoveFramesWindow `;
string $form = `formLayout `; // whole form
string $scroll = `scrollLayout -cr 1 ` ;
string $columnLayout = `columnLayout -adj 1 -cat "both" 2`;
setParent $form;
string $addButton = `symbolButton
-image "setEdAddCmd.xpm"
-height 24 -width 24
-c ("addAFrame "+ $columnLayout)`;
setParent $form;
formLayout -edit
-attachForm $addButton "top" 5
-attachForm $addButton "left" 5
-attachNone $addButton "right"
-attachNone $addButton "bottom"
-attachControl $scroll "top" 5 $addButton
-attachForm $scroll "right" 5
-attachForm $scroll "left" 5
-attachForm $scroll "bottom" 5
$form ;
showWindow $win;
}
// set the columnLayout as the parent and make a new frameLayout in it.
// set the label to the time it was created so we can see that
// the correct frame gets deleted when the remove button is pressed
global proc addAFrame(string $columnLayout) {
setParent $columnLayout;
string $timeNow = `about -currentTime`;
string $frameLayout = `frameLayout -cll 1 -cl 0 -l $timeNow`;
button -l "Remove Me" -c ("deleteUI " + $frameLayout);
}