Search code examples
pythontkinterwindowresizeresizable

How to make a window' size can be decreased to a certain size using Tkinter?


I want to make a window can be decreased to a certain size (for example 200x200) using Tkinter, but I only found that either can be resizable (using resizable() method) or not. For example

from tkinter import *

v = tk()
v.geometry('500x500')
v.mainloop()

So I want that this window can be decreased until 200x200, not less.


Solution

  • From what I gather from your answer, you are trying to set a minimum window size in tkinter. Here is some code that does just that:

    from tkinter import * 
    from tkinter.ttk import * 
    from time import strftime
      
    
    root = Tk()
      
    # setting the minimum size of the root window
    root.minsize(150, 100)
      
    # Adding widgets to the root window
    Label(root, text = 'Sample Window',font = ('Verdana', 15)).pack(side = TOP, pady = 10)
    Button(root, text = 'Click Me!').pack(side = TOP)
      
    mainloop()