'Python tkinter treeview making 2 columns
from Tkinter import Tk, Button
import ttk
root = Tk()
tree = ttk.Treeview(root)
tree["columns"]=("one")
tree.column("one" )
# tree.column("two", width=100)
tree.insert("" , 0, values=("1A"))
def edit():
x = tree.get_children()
for item in x: ## Changing all children from root item
tree.item(item, text="blub", values=("foo", "bar"))
def delete():
selected_item = tree.selection()[0] ## get selected item
tree.delete(selected_item)
tree.pack()
button_del = Button(root, text="del", command=delete)
button_del.pack()
button_del = Button(root, text="edit", command=edit)
button_del.pack()
root.mainloop()
I'm trying just to make 1 column using the treeview. But it keeps making one blank one and one that I want it to make. Also when i create 2 columns it makes 3 in total. Not what I want. Tried playing around with the code and no luck. Thanks
Solution 1:[1]
When creating your treeview, just add show = 'headings'
so you would get something like this:
tree = ttk.Treeview(root, show='headings')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Magnus Filsø |