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

Time:06-25

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.

CodePudding user response:

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()

Hope that helps! I am new to stackoverflow.

CodePudding user response:

To make that you need to do something like this-

from tkinter import *

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

OR

from tkinter import*
w= tk()
w.minsize('123') #for minimum size 
w.maxsize('123') #for maximum size
w.mainloop()
  • Related