ttk.Treeview – Change item text

You can change an existing row’s text.

img

treeview_customers.item("I001", text="Another", values=("Name",))

We simply use the .item() method to change a row’s text.

More info

First we need to tell the .item() method which row we want to alter. We do this by passing in the iid of the item we want to change. In the example above, the first row item has an iid of I001.

Passing text= will change the first column’s text (column “#0”). Passing values= will change the other columns’ text.

If you only want to change the second column’s text (the Last Name column), but not the first column’s text, that is also possible.

# We just have to leave out the text= part.
treeview_customers.item("I001", values=("New Last Name",))

img

Similarly, if you only want to change the text in the first column, use text=

# Pass in text=, but not values= 
# to change the text only in the first column.
treeview_customers.item("I001", text="New First Name")

img