ภาพรวม
เพื่อทำให้ Tkinter Widget ไม่มองเห็น ใช้เมธอด pack_forget() โดยปกติใช้ Unmap Widgets จากหน้าต่าง
ตัวอย่างโค้ด
# Import the required libraries
from tkinter import *
# Create an instance of tkinter frame
win = Tk()
# Set the geometry of frame
win.geometry("600x250")
# Set the resizable property False
win.resizable(False, False)
# Make the widgets Invisible
def make_invisible(widget):
widget.pack_forget()
# Create a label for the window or frame
label = Label(win, text="Hello World!", font=('Helvetica bold', 20), anchor="center")
label.pack(pady=20)
# Create a button to make the widgets invisible
btn = Button(win, text="Click", font=('Helvetica bold', 10), command=lambda: make_invisible(label))
btn.pack(pady=20)
win.mainloop()
ผลลัพธ์
รันโค้ดจะผลลัพธ์หน้าต่างดังนี้

คลิก "Click" Button ทำให้ Text Label Invisible
