Search code examples
pythontkinter

Tkinter/Python Treeview change header


I'm having a problem using the treeview. I need a listbox, that can have multiple columns, that i can display data, collected from a SQL database. My problem with the treeview is that is first column name, can't be changed.

table = ttk.Treeview(frame2, columns=['widgets'])
table.heading('widgets', text='Item')
table.pack()

You would imagin that this, would create a treeview with one column, and then rename the header to item. It creates two columns where the last one is called item and the first empty. Example

Is there a way to change the first comlumn name or is there a better way doing this?


Solution

  • Use the column identifier "#0" to change the heading of the tree column:

    table.heading('#0', text='Name')