How can I get `cget` to return the correct size of a resized
widget?
(`.widget cget -width|height` returns the wrong size!)
|
| |
Don`t use a widget`s `cget` method, use ``winfo` width|height .widget`
instead. The `cget` method will only tell you what the widget wanted to
be or what you told it to be with `.widget configure -width|height ...`.
If the packer resizes it to fill the slave space, or the user resizes
it, then only `winfo` will return the actual new size. To summarise:
cget -width
cget -height
These give you back the size that you asked for in units specific to the
widget, e.g. it could be pixels, lines, characters, miles etc. This size
is used by the widget to calculate the initial size in pixels of the
whole widget (including borders etc.). The meaning of these options is
totally widget specific.
winfo reqwidth
winfo reqheight
This gives you the size in pixels that the widget has calculated is
optimal given all of the options set on that widget. This information is
passed to the geometry manager which decides what the actual size of the
widget should be.
winfo width
winfo height
These give you the actual size of the widget as set by the geometry
manager. This may be larger or smaller then the requested size.
|
|
|