Tkinter Sizegrip

Summary: in this tutorial, you’ll learn how to use the Tkinter Sizegrip widget that allows you to resize the entire application window.

Introduction to the Tkinter Sizegrip widget

The Sizegrip widget typically locates in the bottom right corner of the window. It allows you to resize the enter application window:

To create a Sizegrip widget, you use the following syntax:

ttk.Sizegrip(parent, **option)
Code language: Python (python)

To make sure the Sizegrip widget works properly, you need to make the root window resizable.

If you use the grid geometry manager, you need to configure column and row sizes.

Tkinter Sizegrip widget example

The following program displays a Sizegrip at the bottom right of the root window:

import tkinter as tk from tkinter import ttk root = tk.Tk() root.title('Sizegrip Demo') root.geometry('300x200') root.resizable(True, True) # grid layout root.columnconfigure(0, weight=1) root.rowconfigure(0, weight=1) # create the sizegrip sg = ttk.Sizegrip(root) sg.grid(row=1, sticky=tk.SE) root.mainloop()
Code language: Python (python)

Output:


How it works.

First, make sure the root window resizable:

root.resizable(True, True)
Code language: Python (python)

Second, configure the grid layout:

root.columnconfigure(0, weight=1) root.rowconfigure(0, weight=1)
Code language: Python (python)

Third, create a Sizegrip widget:

sg = ttk.Sizegrip(root) sg.grid(row=1, sticky=tk.SE)
Code language: Python (python)

Summary

  • Use the Tkinter Sizegrip widget to allow users to resize the entire window application.
Did you find this tutorial helpful ?