Monday, November 24, 2025
HomeLanguagesHow to Set a Tkinter Window With a Constant Size?

How to Set a Tkinter Window With a Constant Size?

Prerequisite:

The task here is to produce a Tkinter window with a constant size. A window with a constant size cannot be resized as per users’ convenience, it holds its dimensions rigidly. A normal window on the other hand can be resized.

Approach

  • Import module
  • Declare Tkinter object
  • Create a fixed sized window using maxsize() and minsize() functions.

Syntax:

Here, height and width are in pixels.

minsize(height, width)

In Tkinter, minsize() method is used to set the minimum size of the Tkinter window. Using this method a user can set window’s initialized size to its minimum size, and still be able to maximize and scale the window larger.

maxsize(height, width)

This method is used to set the maximum size of the root window. User will still be able to shrink the size of the window to the minimum possible.

Program 1: Creating a normal window

Python3




# Import module
from tkinter import *
 
# Create object
root = Tk()
 
# Adjust size
root.geometry("400x400")
 
# Execute tkinter
root.mainloop()


Output:

 

Program 2: Creating a window with constant size

Python3




# Import module
from tkinter import *
 
# Create object
root = Tk()
 
# Adjust size
root.geometry("400x400")
 
# set minimum window size value
root.minsize(400, 400)
 
# set maximum window size value
root.maxsize(400, 400)
 
# Execute tkinter
root.mainloop()


Output:

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32410 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6785 POSTS0 COMMENTS
Nicole Veronica
11932 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12000 POSTS0 COMMENTS
Shaida Kate Naidoo
6909 POSTS0 COMMENTS
Ted Musemwa
7168 POSTS0 COMMENTS
Thapelo Manthata
6865 POSTS0 COMMENTS
Umr Jansen
6852 POSTS0 COMMENTS