maxsize() method in Tkinter | Python
This method is used to set the maximum size of the root window (maximum size a window can be expanded). User will still be able to shrink the size of the window to the minimum possible.
Syntax :
master.maxsize(height, width)
Here, height and width are in pixels.
Code #1:
# 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() |
Output :
Initial size of the window (maximum size of the window is not set)

Expanded size of the window (this window can be expanded til the size of the screen because size is not fixed).

Code #2: Fixing maximum size of the root window
# importing only those functions # which are needed from tkinter import * from tkinter.ttk import * from time import strftime # creating tkinter window root = Tk() # Fixing the size of the root window. # No one can now expand the size of the # root window than the specified one. root.maxsize(200, 200) # 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() |
Output :
Maximum expanded size of the window

Note: Tkinter also offers a minsize() method which is used to set the minimum size of the window.
Recommended Posts:
- Python | after method in Tkinter
- Python | pack() method in Tkinter
- destroy() method in Tkinter | Python
- resizable() method in Tkinter | Python
- minsize() method in Tkinter | Python
- Python | place() method in Tkinter
- iconphoto() method in Tkinter | Python
- Python | geometry method in Tkinter
- Python | grid() method in Tkinter
- Python Tkinter | grid_location() and grid_size() method
- Python | forget_pack() and forget_grid() method in Tkinter
- Python Tkinter | Moving objects using Canvas.move() method
- Python GUI - tkinter
- RadioButton in Tkinter | Python
- Different messages in Tkinter | Python
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.



