Open In App

maxsize() method in Tkinter | Python

Last Updated : 11 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

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: 

Python3
# 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) Initial size of the window Expanded size of the window (this window can be expanded till the size of the screen because size is not fixed). Expanded size of the window   Code #2: Fixing maximum size of the root window 

Python3
# 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 Maximum expanded size of the window Note: Tkinter also offers a minsize() method which is used to set the minimum size of the window.


Practice Tags :

Similar Reads

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy