Tk Source Code

View Ticket
Login
Ticket UUID: 678939
Title: reqwidth and reqheight not reset
Type: Bug Version: None
Submitter: markgsaye Created on: 2003-02-02 07:21:43
Subsystem: 48. Geometry Management Assigned To: chengyemao
Priority: 5 Medium Severity:
Status: Pending Last Modified: 2026-09-23 13:28:49
Resolution: Wont Fix Closed By:
    Closed on:
Description:
A frame's reqwidth and reqheight are not reset after
children/slaves are removed.

When a frame is created (with default -width 0 -height
0), the frame has a reqwidth and reqheight of 1 pixel.
When packing/griding a child label, for example, the
frame's reqwidth/height increases to accomodate its
child. After the child widget is
destroyed/unpacked/ungrided, I believe the frame's
reqwidth/height should return to 1 pixel, but it
remains the same.

  set f [frame .f]
  set l [label .f.l -text "Hello World"]

  pack $f -e 1 -f both
  puts "$f reqwidth='[winfo reqwidth $f]'
reqheight='[winfo reqheight $f]'"

  pack $l
  update
  puts "$f reqwidth='[winfo reqwidth $f]'
reqheight='[winfo reqheight $f]'"

  destroy $l
  update
  puts "$f reqwidth='[winfo reqwidth $f]'
reqheight='[winfo reqheight $f]'"

returns:

.f reqwidth='1' reqheight='1'
.f reqwidth='71' reqheight='20'
.f reqwidth='71' reqheight='20'

This happens on Linux, tcl_patchLevel 8.3.4 / 8.4.0 / 8.4.1
User Comments: serhiy.storchaka added on 2026-09-23 13:28:49:

Reproducible, but it is deliberate. When the last content window is removed, ArrangePacking() returns without making a geometry request (generic/tkPack.c), and ArrangeGrid() does the same (generic/tkGrid.c), with the comment:

If the container has no content anymore, then leave the container's size as-is.
Otherwise there is no way to "relinquish" control over the container
so another geometry manager can take over.

So the requested size stays at the value from the last layout, after destroy, pack forget and grid forget alike. A script which wants the original size back can set -width and -height on the container itself.


markgsaye added on 2003-09-04 11:37:24:
Logged In: YES 
user_id=264793

wm geometry . {} doesn't affect the requested size of a
frame widget.

A workaround is to set the width/height of the parent to 1
and back to 0 i.e.:

  destroy $l
  $f configure -width 1 -height 1
  $f configure -width 0 -height 0

hobbs added on 2003-07-17 08:17:16:
Logged In: YES 
user_id=72656

did you try the geom reset'ing command 'wm geom . {}' ?