Window Manager เป็นชุดเครื่องมือที่มีอยู่ใน Tcl/Tk ซึ่งสามารถเข้าถึงได้ด้วยคำสั่ง 'wm' คำสั่ง 'wm' ช่วยให้คุณตั้งค่าการแสดงผลและเรขาคณิตของหน้าต่าง Tkinter ได้ เราสามารถควบคุมหัวข้อ สี ขนาด และคุณสมบัติอื่นๆ ด้วยคำสั่งนี้ คำสั่ง 'wm' มีคีย์เวิร์ดจำนวนมากที่สามารถนำมาใช้ปรับเปลี่ยนคุณสมบัติได้
ตัวอย่าง
# Import the required library
from tkinter import *
from tkinter import ttk
from tkinter import messagebox
# Create an instance of tkinter frame
win = Tk()
# Set the geometry
win.geometry("700x350")
Label(win, text="This window is disabled.", font=("Calibri", 24)).pack()
# Makes the window topmost
win.wm_attributes('-topmost', True)
# Makes the window transparent
win.wm_attributes('-alpha', 0.9)
# Disable the window
win.wm_attributes('-disabled', True)
# Set the geometry of the window
win.wm_geometry('700x350')
win.mainloop()
ผลลัพธ์
เมื่อรันโค้ดด้านบน จะแสดงหน้าต่างที่อยู่ชั้นบนสุด โปร่งแสง และไม่สามารถโต้ตอบได้ เนื่องจากหน้าต่างถูกปิดใช้งานด้วยคุณสมบัติ wm คือ "-disabled"
