How to Freeze the Tkinter Window Frame Size

Jinku Hu Feb 02, 2024
  1. Frame resizable Method
  2. Frame minsize and maxsize Method
How to Freeze the Tkinter Window Frame Size

In some scenarios, we want the Tkinter window frame size is frozen, or in other words, the frame is not resizable. For example, the window frame keeps the same no matter the label widget in the frame is too long or too short.

Frame resizable Method

resizable(width= , height=) configures the frame window size resizable or not in width and height.

resizable(width = False) only freezes the window width, meanwhile resizable(height = False) only freezes the window height. The whole window size is frozen by using resizable(width=False, height=False), or simply resizable(False, False).

try:
    import Tkinter as tk
except:
    import tkinter as tk


app = tk.Tk()
app.title("Frame Window Size Frozen")
app.geometry("300x200")

app.resizable(width=False, height=False)
app.mainloop()

Frame minsize and maxsize Method

minsize and maxsize methods are normally used to set the minimum and maximum window size, but could also freeze the window size if you set both minimum and maximum sizes to be identical.

try:
    import Tkinter as tk
except:
    import tkinter as tk


app = tk.Tk()
app.title("Frame Window Size Frozen")

app.minsize(width=600, height=400)
app.maxsize(width=600, height=400)
app.mainloop()
Author: Jinku Hu
Jinku Hu avatar Jinku Hu avatar

Founder of DelftStack.com. Jinku has worked in the robotics and automotive industries for over 8 years. He sharpened his coding skills when he needed to do the automatic testing, data collection from remote servers and report creation from the endurance test. He is from an electrical/electronics engineering background but has expanded his interest to embedded electronics, embedded programming and front-/back-end programming.

LinkedIn Facebook

Related Article - Tkinter Geometry