0
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

3
  • you do want to make table?? Commented Dec 23, 2016 at 21:38
  • see Creating a table look-a-like Tkinter and Display Listbox with columns using Tkinter? Commented Dec 24, 2016 at 3:51
  • 1
    Treeview always create first column for tree. If you need only one column then you can use this first column without creating other columns - or use standard Tkinter.Listbox Commented Dec 24, 2016 at 3:55

1 Answer 1

0

When creating your treeview, just add show = 'headings' so you would get something like this:

tree = ttk.Treeview(root, show='headings')

Resulting treeview (picture)

Sign up to request clarification or add additional context in comments.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.