While typically users are given the option to resize GUI windows at will, there may be times where you wish to disable the resizing feature for a Tkinter window. For instance, your GUI window may not support resizing. If you weren’t careful with how you packed/placed the objects into the window, resizing will ruin your set up.
Luckily, there is an easy one line fix to this issue.
import tkinter as tk
root = tk.Tk()
root.geometry("200x150")
label = tk.Label(root, text = "Hello World")
label.pack(padx = 5, pady = 5)
root.resizable(False, False)
root.mainloop()
Since the user has the option to resize the Tkinter window for both the X ad Y axis, we too have the option to disable resizing individually for the X and Y axis. Passing two False arguments into the resizable function will disable both.
Remember to call the resizable function before the mainloop() function but after the tk.Tk() function.
See more Tkinter related tit bits below.
List of Tkinter Widgets
How to improve Tkinter screen resolution?
How to change font type and size in Tkinter?
Top comments (0)