How to index through treeview.item values

Viewed 123

The code below changes each item in the row at each of the different columns. In this case six columns.

for child in treeview.getchildren():
    treeview.item(child, values=('1', '2', '3', '4', '5', '6'))

Let's say I wanted to change a value of a cell in a specific row of my treeview. The treeview has 6 columns and I want to change the value of let's say the 5th column.

for child in treeview.get_children():
    treeview.item(x, option='values')[4]

The code above is to select it, but I want to change the value of '5' in let's say '10'. How would I do that?

Any help is appreciated.

1 Answers

You can use Treeview.set():

# assume column name for 5th column is 'col5'
for child in treeview.get_children():
    treeview.set(child, 'col5', '10')
Related