我的問題:當我選擇一行時,我無法向 Text 小部件顯示值。
如何在選定行的Text 小部件內顯示值?
我嘗試在 Text 小部件中使用textvariable屬性,但它不起作用。

uj5u.com熱心網友回復:
小部件的使用insert方法Text。最小的例子:
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(tk.END, f"Some text\n")
tk.Button(root, text="Add text", command=add_text).pack()
root.mainloop()
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/365756.html
