I have a treeview and have inserted some data into it as shown below.
self.tree.insert('', 'end', iid="test1", text="test a", values=("data1", "data2"))
This adds an entry to the end of the treeview with text "test a" and column values of "data1" and "data2".
The iid has been set to "test1".
I would like to return the value of iid of an item in the treeview so that I can use it for some other function (I will be storing a file path in this iid)
I tried using treeview.item() and this returned the following dictionary without the iid:
{'version': 'data1', 'author': 'data2'}
(where version and author are the column headings)
So my question: is there a simple way to return the iid of a given row/entry to the treeview?
To get the iid
you can use the identify()
function:
tree.identify(event.x, event.y) # item at row "x" and column "y"
The iid
argument stands for item identifier which is unique for each item, and you can give it the value you want.