How do I get a window's current size using Tkinter?
Asked Answered
J

2

23

How do I get a windows current size using Tkinter, or possibly with the python standard library?

Judkins answered 31/10, 2010 at 23:39 Comment(2)
duplicate : #3950344Alderney
@mouad: No, not a dup of that.Cadi
T
35

Use the following universal widget methods (where w is a widget):

w.winfo_height()
w.winfo_width()

You can also use the following:

w.winfo_reqheight()
w.winfo_reqwidth()

Read about Universal widget methods.

Trounce answered 1/11, 2010 at 0:0 Comment(1)
be aware that those two can give drastically different results. _height/_width give the actual sizes.Haynie
L
2

The answers above did not give me the correct result. Here is my solution to get the correct current window size (in pixel).

w._current_width
w._current_height
Lugworm answered 14/3 at 1:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.