How to set a Tkinter window to a constant size?

TkinterPythonServer Side ProgrammingProgramming

Whenever we run our tkinter application, it displays a window of certain size (i.e., width and height of the window). In order to set the window size constant or non-resizable, we will use the resizable() method.

Generally, the method takes two values, i.e., the width and height of the window. In order to make the window size constant, we can assign NULL or Zero to both width and height in the function parameters.

Example

#Import the tkinter library
from tkinter import *

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

#Set the geometry
win.geometry("650x350")

#Make Constant size Window
win.resizable(False, False)

#Create a Label
Label(win, text= "Hello!", font= ('Helvetica bold', 15)).pack(pady= 20)

win.mainloop()

Output

Running the above code will display a constant size window.

raja
Published on 26-Mar-2021 10:33:27
Advertisements