![](/img/trans.png)
[英]How to set the text/value/content of an `Entry` widget using a button in tkinter
[英]how to set value in Text widget in tkinter?
使用Text
小部件的insert
方法。 最小的例子:
import tkinter as tk
root = tk.Tk()
text = tk.Text(root)
text.pack()
def add_text():
# text.delete(1.0, tk.END) # Uncomment if you need to replace text instead of adding
text.insert(1.0, f"Some text\n")
tk.Button(root, text="Add text", command=add_text).pack()
root.mainloop()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.