如何仅在表的“名称”列中添加名称?

时间:2019-02-13 02:55:54

标签: python tkinter treeview

我正在使用tkinter创建一个狗头王牌风格的游戏,并且需要它也仅在“名称”列中显示名称,而是将名称分布在所有列中

labelText.set("These are your cards")
tree = ttk.Treeview(root,columns=("Name","Exercise","Intelligence","Friendliness","Drool"))
tree["show"]= "headings"
namecol = tree.heading("Name", text="Name")
tree.heading("Exercise", text="Exercise")
tree.heading("Intelligence", text="Intelligence")
tree.heading("Friendliness", text="Friendliness")
tree.heading("Drool", text="Drool")

tree.grid(row=6,column=0,columnspan=5)

lbl = tkinter.Label(root, text="Your Cards")
lbl.grid(column=0, row=5, columnspan=5)


#creates a list with each dog in it
dogs = []

with open("dogs.txt", "rt") as in_file:
    for dog in in_file:
        dogs.append(dog)


for value in dogs:
    tree.insert("", "0", value=dogs)

最后,我在所有列上而不是在名称列上显示文本文件,而不是仅在名称中显示

1 个答案:

答案 0 :(得分:1)

Map<String, String>

收件人

for value in dogs:
    tree.insert("", "0", value=dogs)