maxsize () method in Tkinter | python

Python Methods and Functions

Syntax :

 master.maxsize (height, width) 

Height and width here in pixels.

Code # 1:

# import only these functions
# which needed

from tkinter import *

from tkinter.ttk import *  

from time import strftime

  
# create a 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 window size (no maximum window size is set)

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

Code # 2: Fix the maximum size of the root window

# import only these functions
# which are needed

from tkinter import *  

from tkinter.ttk import *  

from time import strftime

 
# create a tkinter window

root = Tk ()

 
# Fix the size of the root window .
# Now no one can expand the size
# 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 extended window size

Note:

Get Solution for free from DataCamp guru