Is there a way to find dimensions of a frame in tkinter?

Viewed 23

I am trying to append an image to a frame I have. However, I have many frames within each other so I don't know what the dimensions of this frame are. Is there any function or anything that will output the dimensions of the frame like "100x500", for example?

Thanks

1 Answers

Every widget has the methods winfo_width and winfo_height which return the current dimensions of the widget. You can also use winfo_reqwidth and winfo_reqheight to get the requested width and height. The two can be different if the size of the widget changes due to how it is managed (eg: when using sticky with grid, or fill with pack.

If the window has not yet actually been rendered, the width and height returned by winfo_width and winfo_height will be 1.

Related