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
from tkinter import *
from tkinter.ttk import *
from time import strftime
root = Tk()
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 till the size of the screen because size is not fixed).
Code #2: Fixing maximum size of the root window
Python3
from tkinter import *
from tkinter.ttk import *
from time import strftime
root = Tk()
root.maxsize( 200 , 200 )
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.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
10 Jan, 2023
Like Article
Save Article