values 值是路径时无法识别是怎么回事?
2个问题1.请问(tree.F2 = tree.insert("",1,"英国",text="英国",values=("F:\software python\学习资料"))),中的 values 值是路径时无法识别是怎么回事?
2.如何设置各个节点是不展开的?
谢谢各位啦!!!
import tkinter
from tkinter import ttk
win = tkinter.Tk()
win.title("fcl")
win.geometry("400x400")
tree =ttk.Treeview(win)
tree.F1 = tree.insert("",0,"中国",text="中国",values=("zzzz"))
tree.F2 = tree.insert("",1,"英国",text="英国",values=("F:\software python\学习资料"))
tree.pack()
ev = tkinter.Variable()
entry = tkinter.Entry(win,textvariable=ev)
entry.pack()
def func(event):
v = event.widget.selection()
for sv in v:
file = tree.item(sv)["text"]
ev.set(file)
print(file)
apath = tree.item(sv)["values"][0]
print("apath",apath)
tree.bind("<<TreeviewSelect>>",func)
win.mainloop()