我在tkinter中制作了一个简单的树视图。是否可以在tkinter treview中创建一个网格,以使它看起来更像一张桌子?
我想让它更“用户友好”,因此可以更好地显示表/树视图。
from tkinter import *
from tkinter import ttk
myApp = Tk()
myApp.title(" Program ")
myApp.geometry("800x700")
tree = ttk.Treeview(myApp,height=25)
tree['show'] = 'headings'
sb = ttk.Scrollbar(myApp, orient="vertical", command=tree.yview)
sb.grid(row=1,column=1,sticky="NS",pady=5)
tree.configure(yscrollcommand=sb.set)
tree["columns"]=("1","2","3")
tree.column("1", width=50)
tree.column("2", width=50)
tree.column("3", width=50)
tree.heading("1", text="Col 1")
tree.heading("2", text="Col 2")
tree.heading("3", text="Col 3")
item = tree.insert("", "end", values=("",))
tree.grid(row=1,column=0,padx=5,pady=5)
myApp.mainloop()
答案 0 :(得分:0)
I believe that the only option to make it more "user-friendly" is to create alternating row colors:
tree.insert("", "end", values=("a",),)
tree.insert("", "end", values=("b",), tag='gray')
tree.insert("", "end", values=("c",),)
tree.insert("", "end", values=("d",), tag='gray')
tree.tag_configure('gray', background='#cccccc')