[英]remove text when click left-click on entry tkinter python?
我最近一直試圖讓輸入文本在 python tkinter 中消失,以向用戶顯示在哪里輸入特定內容但是當我輸入文本時會發生什么,它將在那里並且用戶必須手動刪除所有文本這是我的代碼
import tkinter as tk
root = tk.Tk()
entry = tk.Entry(root )
entry.insert(0, "enter the text here")
entry.pack()
root.mainloop()
用entry.bind("<Button-1>", lambda e: entry.delete(0, tk.END))
。
代碼:
import tkinter as tk
root = tk.Tk()
entry = tk.Entry(root)
entry.bind("<Button-1>", lambda e: entry.delete(0, tk.END))
entry.insert(0, "enter the text here")
entry.pack()
root.mainloop()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.