[Tkinter-discuss] question on winfo_height

Michael Lange klappnase at web.de
Wed Apr 10 19:05:54 CEST 2013


Hi,

On Wed, 10 Apr 2013 10:20:35 -0500
Bryan Oakley <bryan.oakley at gmail.com> wrote:

> winfo_height returns the actual, absolute height of the window. It's
> not relative to anything.
> 
> The reason the value is 1 is because the frame has yet to be displayed
> on the screen. It is the actual updating of the screen that gives a
> widget its dimensions, since that depends on the size of the
> containing window, how it is packed or gridded, what is inside of the
> frame, etc. None of that can be determined until the window is
> actually mapped to the display.
> 
> Simply calling update will cause it to be displayed and thus give you
> a reasonable number, though calling update is a relatively risky thing
> to do.

I think update_idletasks() instead of update() should be sufficient; to
query the widget's initial size you can also try the winfo_reqheight() and
winfo_reqwidth() methods.

Regards

Michael


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

After a time, you may find that "having" is not so pleasing a thing,
after all, as "wanting."  It is not logical, but it is often true.
		-- Spock, "Amok Time", stardate 3372.7


More information about the Tkinter-discuss mailing list