minsize() method in Tkinter | Python

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

Syntax:

master.minsize(height, width)

Here, height and width are in pixels.



Code #1: Root window without minimum size that means you can shrink window as much you want.

filter_none

edit
close

play_arrow

link
brightness_4
code

# importing only  those functions
# which are needed
from tkinter import * 
from tkinter.ttk import *
from time import strftime
  
# creating tkinter window
root = Tk()
  
# Adding widgets to the root window
Label(root, text = 'GeeksforGeeks'
      font =('Verdana', 15)).pack(side = TOP, pady = 10)
  
Button(root, text = 'Click Me !').pack(side = TOP)
  
mainloop()

chevron_right


Output:
Initial root window without alteration in size

Root window after shrunken down, see the window is completely shrunken because it has no minimum geometry.

Code #2: Root window with minimum size.

filter_none

edit
close

play_arrow

link
brightness_4
code

# importing only  those functions
# which are needed
from tkinter import * 
from tkinter.ttk import * 
from time import strftime
  
# creating tkinter window
root = Tk()
  
# setting the minimun size of the root window
root.minsize(150, 100)
  
# Adding widgets to the root window
Label(root, text = 'GeeksforGeeks'
      font =('Verdana', 15)).pack(side = TOP, pady = 10)
Button(root, text = 'Click Me !').pack(side = TOP)
  
mainloop()

chevron_right


Output:
Initial window

Expanded window (we can expand window as much as we want because we haven’t set the maximum size of the window).

Window shrunken to it’s minimum size (one cannot shrunk it any further).



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.