grid forget

grid forget slave ?slave ...?

Removes each of the slaves from grid for its master and unmaps their windows. The slaves will no longer be managed by the grid geometry manager. The configuration options for that window are forgotten, so that if the slave is managed once more by the grid geometry manager, the initial default settings are used.


If all widgets contained in a grid are unmapped using destroy or grid forget, there might still be row or column states set by grid rowconfigure or grid columnconfigure. Their existance might be observed by grid size not returning 0 0:

% frame .f
% grid size .f
0 0
% grid rowconfigure .f 1 -weight 1
% grid size .f
0 2
% grid rowconfigure .f 1 -weight 0
% grid size .f
0 0

Here is a procedure to clear all grid memory:

proc gridClear {path} {
    grid forget {*}[winfo children $path]
    lassign [grid size $path] cols rows
    for {set row 0} {$row < $rows} {incr row} {
        grid rowconfigure $path $row -minsize 0 -weight 0 -uniform "" -pad 0
    }
    for {set col 0} {$col < $cols} {incr col} {
        grid columnconfigure $path $col -minsize 0 -weight 0 -uniform "" -pad 0
    }
}

A better (and more future save in respect of eventual new options) way is to destroy and recreate the parent:

% destroy .f
% frame .f

See also