Tkinter – Create Non-resizable Window

Tkinter – Non-resizable window

In Tkinter, you can create a non-resizable window using resizable() method of the Tk window object.

To create a non-resizable window in Tkinter, call resizable() method on the main window (Tk object), and pass False for the both width and height options.

window = tk.Tk()
window.resizable(False, False)

where the two arguments passed to the method are width and height, boolean values, that specify whether the window can be resized along horizontal or vertical axis, respectively.

Now, let us go through an example.

Examples

1. Non resizable window in Tkinter

In this example, we shall create a Tkinter window that cannot be resized along width or height.

Python Program

import tkinter as tk

# Create the main window
window = tk.Tk()
window.title("PythonExamples.org")

# Set windows as non-resizable
window.resizable(False, False)

window.mainloop()

Output in MacOS

Tkinter - Non-resizable window
Tkinter – Non resizable window

This window cannot the resized. Besides resizing, if you observe the window controls, only the minimize and close buttons of the window are active, and the maximize button is inactive.

Summary

In this Python Tkinter tutorial, we have seen how to create a non-resizable window using resizable() method of the Tk window in Tkinter, with examples.

Related Tutorials

Code copied to clipboard successfully 👍