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 and the Y axis, we too have the option to disable resizing individually for the X and Y axis. Passing two boolean values “False” as arguments into the resizable function will disable both.

Remember to call the resizable function before the root.mainloop() function but after the tk.Tk() function.

On the other hand, if you want to learn how to properly manage the layout of your window, then take a look at the concept of “Sizers” in wxPython, which controls the way your widgets appear. (e.g, adjusting their size and position as the window size increases or decreases)


This marks the end of the disable Tkinter Window resizing article. Any suggestions or contributions for CodersLegacy are more than welcome. Any questions can be asked in the comments section below.

See more Tkinter related tit bits below.
How to improve Tkinter screen resolution?
How to change font type and size in Tkinter?
How to make an EXE for your Tkinter Application?

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments