winfo reqwidth

winfo reqwidth window

Returns a decimal string giving window 's requested width, in pixels. This is the value used by window 's geometry manager to compute its geometry.


MGS [2003/09/16] - Note that when you un-manage or destroy the child of a frame (for instance), the requested size of that frame does not reduce:

  % frame .f -width 0 -height 0
  .f
  % label .f.l -text "Hello World"
  .f.l
  % pack .f.l
  % winfo reqwidth .f
  76
  % .f.l configure -text "Hello"
  % winfo reqwidth .f
  36
  % pack forget .f.l
  % winfo reqwidth .f
  36

In order to reset the requested size of the frame, just configure its -width to 1 and then 0:

  % .f configure -width 1
  % .f configure -width 0
  % winfo reqwidth .f
  1

The same technique works for the requested height too.