![](/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.