Tkinter เป็นไลบรารี Python ที่ใช้สำหรับการสร้างและพัฒนาแอปพลิเคชันที่ใช้ GUI ในบทความนี้ เราจะมาดูวิธีลบข้อความออกจากป้ายกำกับที่จะมีข้อความอยู่
ในการลบข้อความออกจากป้ายกำกับ เราจะสร้างปุ่มที่เกี่ยวข้องซึ่งจะทำหน้าที่เป็นตัวกระตุ้นสำหรับป้ายกำกับ
ตัวอย่าง
#import Tkinter Library
from tkinter import *
#Create an instance of tkinter frame
win= Tk()
#Define the size and geometry of the frame
win.geometry("700x400")
#Create a function for the Button Comman
def remove_text():
text.config(text=" ")
#Create a text Label
text= Label(win, text= "www.tutorialspoint.com", font= ("Poppins", 30))
text.pack(pady=20)
#Create a Button
my_button= Button(win, text= "Remove Text", command= remove_text)
my_button.pack(pady=10)
win.mainloop() ผลลัพธ์
การเรียกใช้โค้ดด้านบนจะสร้างปุ่มที่สามารถใช้ลบข้อความออกจากป้ายกำกับได้

ตอนนี้ให้คลิกปุ่ม "ลบข้อความ" มันจะลบข้อความออกจากฉลากและเราจะได้รับหน้าจอต่อไปนี้
