Tkinter ttk Sizegrip Widget

In this Tkinter tutorial we will be discussing the ttk Sizegrip widget. The Sizegrip widget is basically a small arrow-like grip that is typically placed at the bottom-right corner of the screen. Dragging the Sizegrip across the screen also resizes the container to which it is attached to (usually the main window).


Tkinter Sizegrip – Syntax

Syntax required to create the ttk Sizegrip Widget.

sizegrip = ttk.Sizegrip(parent, **options)

Has no specific options or unique methods, besides the ones available to all widgets from ttk.Widget class.


Tkinter Sizegrip Example

Remember the tk.SE anchor, as this binds the Sizegrip widget to the “South East” position in the window, which is what “SE” stands for. Similarly, the expand and fill settings ensure the Sizegrip ends up at the bottom-right corner.

import tkinter as tk
import tkinter.ttk as ttk


class Window:
    def __init__(self, master):
        self.master = master

        frame = ttk.Frame(self.master)

        label = ttk.Label(self.master, text = "Hello World")
        label.pack(padx = 5, pady = 5)

        sizegrip = ttk.Sizegrip(frame)
        sizegrip.pack(expand = True, fill = tk.BOTH, anchor = tk.SE)
        
        frame.pack(padx = 10, pady = 10, expand = True, fill = tk.BOTH)
        

root = tk.Tk()
root.geometry("200x150")
window = Window(root)
root.mainloop()

The output: (Notice that little Sizegrip located near the bottom-right)

Tkinter ttk Sizegrip Example

After dragging the slider to increase the size of the window: