ttk.Treeview – Insert rows

We can insert a row in the tree column (the first column) by using the insert method and passing in the text.

self.treeview_cars.insert(parent="",
                          index=tk.END,
                          text="Mini Van")

img

We can insert values under Mini Van so when it expands, it reveals more information.

# Get the parent item iid
mini_van_iid = self.treeview_cars.insert(parent="",
                                         index=tk.END,
                                         text="Mini Van")

# Add a vehicle under Mini Van
self.treeview_cars.insert(parent=mini_van_iid,
                          index=tk.END,
                          values=("Toyota", "2024"))

img