How can I prevent a window from being resized with tkinter? How can I prevent a window from being resized with tkinter? tkinter tkinter

How can I prevent a window from being resized with tkinter?


This code makes a window with the conditions that the user cannot change the dimensions of the Tk() window, and also disables the maximise button.

import tkinter as tkroot = tk.Tk()root.resizable(width=False, height=False)root.mainloop()

Within the program you can change the window dimensions with @Carpetsmoker's answer, or by doing this:

root.geometry('{}x{}'.format(<widthpixels>, <heightpixels>))

It should be fairly easy for you to implement that into your code. :)


You can use the minsize and maxsize to set a minimum & maximum size, for example:

def __init__(self,master):    master.minsize(width=666, height=666)    master.maxsize(width=666, height=666)

Will give your window a fixed width & height of 666 pixels.

Or, just using minsize

def __init__(self,master):    master.minsize(width=666, height=666)

Will make sure your window is always at least 666 pixels large, but the user can still expand the window.


You could use:

parentWindow.maxsize(#,#);parentWindow.minsize(x,x);

At the bottom of your code to set the fixed window size.