Movatterモバイル変換


[0]ホーム

URL:


Open In App
Next Article:
minsize() method in Tkinter | Python
Next article icon

This method is used to set themaximum 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 neededfromtkinterimport*fromtkinter.ttkimport*fromtimeimportstrftime# creating tkinter windowroot=Tk()# Adding widgets to the root windowLabel(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 neededfromtkinterimport*fromtkinter.ttkimport*fromtimeimportstrftime# creating tkinter windowroot=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 windowLabel(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 windowMaximum expanded size of the windowNote:Tkinter also offers aminsize() method which is used to set the minimum size of the window.


Improve
Practice Tags :

Similar Reads

We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood ourCookie Policy &Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences

[8]ページ先頭

©2009-2025 Movatter.jp