Movatterモバイル変換


[0]ホーム

URL:


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

In Tkinter,minsize() method is used to set the minimum size of theTkinter window. Using this method user can set window's initialized size to its minimum size, and still be able to maximize and scale the window larger. 

Syntax:

master.minsize(width, height)

Here, height and width are in pixels. 

Code #1: Root window without minimum size that means you can shrink window as much you want. 

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 root window without alteration in size

 Initial root window without alteration in size 

Root window after shrunken down, see the window is completely shrunken because it has no minimumgeometry

Root window after shrunken down 

Code #2: Root window with minimum size. 

Python3
# importing only  those functions# which are neededfromtkinterimport*fromtkinter.ttkimport*fromtimeimportstrftime# creating tkinter windowroot=Tk()# setting the minimum size of the root windowroot.minsize(150,100)# 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 window

 Initial window 

Expanded window (we can expand window as much as we want because we haven't set the maximum size of the window). 

Expanded window 

Window shrunken to it's minimum size (one cannot shrunk it any further).

 Window shrunken to it’s minimum size


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