ในการสร้างหน้าต่าง tkinter โดยไม่มีแถบชื่อเรื่อง เราสามารถใช้คุณสมบัติ overrideredirect (บูลีน) ซึ่งปิดใช้งานแผงการนำทางจากด้านบนของหน้าต่าง tkinter อย่างไรก็ตาม ไม่อนุญาตให้ผู้ใช้ปรับขนาดหน้าต่างทันที
หากเราจำเป็นต้องสร้างหน้าต่างที่ปรับขนาดได้โดยไม่มีแถบชื่อเรื่องโดยทางโปรแกรม เราก็สามารถใช้ Sizegrip(พาเรนต์) วิดเจ็ตใน Tkinter Sizegrip วิดเจ็ตเพิ่มความสามารถในการขยายไปยังแอปพลิเคชันที่อนุญาตให้ผู้ใช้ดึงและปรับขนาดหน้าต่างหลัก ในการทำงานกับ Sizegrip วิดเจ็ต เราต้องผูกปุ่มเมาส์และฟังก์ชันที่ปรับขนาดหน้าต่างทุกครั้งที่เราดึงมือจับ
ตัวอย่าง
# Import the required libraries
from tkinter import *
from tkinter import ttk
# Create an instance of tkinter frame or window
win=Tk()
# Set the size of the window
win.geometry("700x350")
# Remove the Title bar of the window
win.overrideredirect(True)
# Define a function for resizing the window
def moveMouseButton(e):
x1=winfo_pointerx()
y1=winfo_pointery()
x0=winfo_rootx()
y0=winfo_rooty()
win.geometry("%s x %s" % ((x1-x0),(y1-y0)))
# Add a Label widget
label=Label(win,text="Grab the lower-right corner to resize the window")
label.pack(side="top", fill="both", expand=True)
# Add the gripper for resizing the window
grip=ttk.Sizegrip()
grip.place(relx=1.0, rely=1.0, anchor="se")
grip.lift(label)
grip.bind("<B1-Motion>", moveMouseButton)
win.mainloop() หากเราเรียกใช้โค้ดข้างต้น จะแสดงหน้าต่างที่ไม่มีแถบชื่อเรื่อง เราปรับขนาดหน้าต่างนี้ได้โดยดึงที่จับจากมุมล่างขวา
ผลลัพธ์
