
sizegrip = ttk.Sizegrip(my_w)
sizegrip.grid(row=2,column=1,sticky='se')
s = ttk.Style()
s.configure('TSizegrip', background='red')
sticky : must be a string containing n, e, s, and/or w
from tkinter import ttk
import tkinter as tk
my_w = tk.Tk()
my_w.geometry("550x240") # width and height of window
my_w.title("www.plus2net.com") # title
my_w.rowconfigure(1,weight=1)
my_w.rowconfigure(2,weight=4)
my_w.columnconfigure(1,weight=1)
s = ttk.Style()
s.configure('TSizegrip', background='red')
font1=['Times',22,'normal'] # font family , size and style
lb1=tk.Label(my_w,text=' Sizegrip for resizing the window ',
height=3, bg='yellow',font=font1)
lb1.grid(row=1,column=1,padx=20,pady=20)
sizegrip = ttk.Sizegrip(my_w)
sizegrip.grid(row=2,column=1,sticky='se')
my_w.mainloop() # Keep the window open
side: must be top, bottom, left, or rightanchor : must be n, ne, e, se, s, sw, w, nw, or center
import tkinter as tk
from tkinter import ttk
# Creating the main window
my_w = tk.Tk()
my_w.geometry('300x200')
s = ttk.Style()
s.configure('TSizegrip', background='red')
# Adding the Sizegrip widget
sizegrip = ttk.Sizegrip(my_w)
#sizegrip.pack(side='bottom',anchor='se')
#sizegrip.pack(side='right',anchor='s')
sizegrip.pack(side='left',anchor='s')
my_w.mainloop()
from tkinter import ttk
import tkinter as tk
my_w = tk.Tk()
my_w.geometry("550x240") # width and height of window
my_w.title("www.plus2net.com") # title
s = ttk.Style()
s.configure('TSizegrip', background='red')
font1=['Times',22,'normal'] # font family , size and style
lb1=tk.Label(my_w,text=' Sizegrip for resizing the window ',
height=3, bg='yellow',font=font1)
lb1.place(x=20,y=10)
sizegrip = ttk.Sizegrip(my_w)
sizegrip.place(x=530,y=220)
my_w.mainloop() # Keep the window open
As we are resizing the window it is better to use relative x, y Positioning.
sizegripi.place(relx=0.96,rely=0.93)
my_w.resizable(width=0,height=0) # No resize
#my_w.resizable(width=1,height=0) # Only width resize is allowed
#my_w.resizable(width=0,height=1) # Only height resize is allowed
#my_w.resizable(width=1,height=1) # Both height and width resize is allowed ( default )
Here is complete code.
import tkinter as tk
from tkinter import ttk
# Creating the main window
my_w = tk.Tk()
my_w.geometry('300x200')
my_w.resizable(width=0,height=0) # No resize of window
#my_w.resizable(width=1,height=0) # Only width resize is allowed
#my_w.resizable(width=0,height=1) # Only height resize is allowed
#my_w.resizable(width=1,height=1) # Both height and width resize is allowed ( default )
s = ttk.Style()
s.configure('TSizegrip', background='red')
# Adding the Sizegrip widget
sizegrip = ttk.Sizegrip(my_w)
sizegrip.pack(side='bottom',anchor='se')
my_w.mainloop()
from tkinter import ttk
import tkinter as tk
my_w = tk.Tk()
my_w.geometry("550x240") # width and height of window
my_w.title("www.plus2net.com") # title
my_w.rowconfigure(1,weight=1)
my_w.rowconfigure(2,weight=4)
my_w.columnconfigure(1,weight=1)
def my_resize(event):
lb1.config(text="Width : " + str(my_w.winfo_width())+ ", Height :" + str(my_w.winfo_height()))
s = ttk.Style()
s.configure('TSizegrip', background='red')
font1=['Times',16,'normal'] # font family , size and style
lb1=tk.Label(my_w,text='',height=3, bg='yellow',font=font1)
lb1.grid(row=1,column=1,padx=20,pady=20)
sizegrip = ttk.Sizegrip(my_w)
sizegrip.grid(row=2,column=1,sticky='se')
my_w.bind("<Configure>", my_resize)
my_w.mainloop() # Keep the window open
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.