您需要为每列定义标题。我不知道你是否想为头文件使用相同的列名,否则这将是我的例子。您可以将文本更改为任何您想要的内容。要定义页眉,你将需要使用header()
这样的:
t.heading("Titolo", text="Titolo")
t.heading("Data", text="Data")
t.heading("Allegati?", text="Allegati?")
这些变化的最终代码应该是这样的:
from tkinter import *
from tkinter.ttk import *
w=Tk()
f = Frame(w)
f.pack()
t = Treeview(f, columns=("Titolo", "Data", "Allegati?"))
t.heading("Titolo", text="Titolo")
t.heading("Data", text="Data")
t.heading("Allegati?", text="Allegati?")
t.pack(padx=10, pady=10)
t.insert("", 1, text="Sample")
w.mainloop()
结果:
设我知道你是否有任何问题。
可能相关:https://stackoverflow.com/questions/36120426/tkinter-treeview-widget-inserting-data – Lafexlos