วิดเจ็ต Tkinter Entry ใช้เพื่อแสดงข้อความบรรทัดเดียว การใช้วิดเจ็ต tkinter Entry เราสามารถตั้งค่าหรือเนื้อหาได้โดยการเรียกใช้ปุ่ม มีการทำงานหลักสองประเภท:แทรก และ ลบ .
การใช้วิดเจ็ตปุ่ม Tkinter เราจะตั้งค่าเนื้อหาของวิดเจ็ตรายการ
ตัวอย่าง
#Import the required libraries
from tkinter import *
#Create an instance of tkinter frame
win= Tk()
#Define a function to change the value
def change_text(txt):
text.delete(0,END)
text.insert(0,txt)
#Set the geometry of frame
win.geometry("600x250")
#Create an Entry Widget
text= Entry(win)
text.pack()
#Create a button to change/set the content
btn= Button(win,text="Set", command=lambda:change_text("My New Text"))
btn.pack(pady=20)
win.mainloop() ผลลัพธ์
การเรียกใช้โค้ดจะแสดงหน้าต่างที่มีปุ่มสำหรับตั้งค่าหรือข้อความของวิดเจ็ตรายการ

ตอนนี้ให้คลิกที่ปุ่ม “Set” เพื่อตั้งค่าใหม่สำหรับ Entry Widget
