How to make a window' size can be decreased to a certain size using Tkinter?
Question:
I want to make a window can be decreased to a certain size (for example 200×200) 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 200×200, not less.
Answers:
To make that you need to do something like this
from tkinter import*
w= tk()
w.minsize('123') #for minimum size
w.maxsize('123') #for maximum size
w.mainloop()
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()
I want to make a window can be decreased to a certain size (for example 200×200) 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 200×200, not less.
To make that you need to do something like this
from tkinter import*
w= tk()
w.minsize('123') #for minimum size
w.maxsize('123') #for maximum size
w.mainloop()
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()