Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tkinter/Python Treeview change header

Tags:

python

tkinter

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?

like image 816
RasmusGP Avatar asked Oct 28 '25 14:10

RasmusGP


1 Answers

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

table.heading('#0', text='Name')
like image 118
Bryan Oakley Avatar answered Oct 31 '25 03:10

Bryan Oakley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!