Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a windows current size using Tkinter?

Tags:

python

tkinter

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

like image 870
rectangletangle Avatar asked Oct 31 '10 23:10

rectangletangle


People also ask

How do you define the size of a window in Python?

To set a specific size to the window when using Python tkinter, use geometry() function on the Tk() class variable. where width and height should be replaced with integers that represent the width and height of the window respectively.

How do you find the width and height of a Tkinter window?

In order to get the width and height of the tkinter window, we can use winfo_width() and winfo_height() helper methods that help to grab the current width and height of the tkinter window.

Which function is used to set the size of the Tkinter window?

In Tkinter, minsize() method is used to set the minimum size of the Tkinter window. Using this method a user can set window's initialized size to its minimum size, and still be able to maximize and scale the window larger.


1 Answers

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.

like image 194
Gary Kerr Avatar answered Oct 02 '22 19:10

Gary Kerr