这是代码的示例:
entry=Entry(root)
entry.insert(0, "This is a read-only widget")
entry.pack()
如何使此条目不可编辑?
您可以将Entry
的state option
设置为disabled
:
import tkinter as tk
root = tk.Tk()
entry = tk.Entry(root)
entry.insert(0, "This is a read-only widget")
entry.config(state='disabled')
entry.pack()
root.mainloop()