How do I set a minimum window size in Tkinter?

TkinterPythonServer Side ProgrammingProgramming

A Tkinter window can be initialized after running the application. Generally, the width and the height of the window is resizable which can be minimized.

In order to set the window size to its minimum value, assign the value of width and height in minsize(height, width) method. The method can be invoked with the window or frame object.

Example

#Import the required libraries
from tkinter import *

#Create an instance of tkinter frame
win= Tk()

#Minimize the window
win.minsize(150, 100)

#Create a text label
Label(win, text= "Window Size is minimized to 150x100",font=('Helvetica bold',20)).pack(pady=20)

win.mainloop()

Output

Running the above code will set the window size to its minimum.

raja
Published on 27-Mar-2021 06:06:21
Advertisements