Python Tkinter TTK Treeview Find Selected Items' ID Or Row
<p>I am creating a program which uses a TTK Treeview as an item hierarchy.
So far, the user is able to insert their own values into the tree, but I need to have a check running for when the user clicks on an item in the tree. I need the check to find the selected items ID and return it.</p>

<p>The check I have running relies on the <code>&lt;&lt;TreeviewSelect&gt;&gt;</code> bind. Currently, it finds the selected item and stores some information, but I need for it to also find the row the item is in or it's ID.</p>

<p>I tried implementing my own tag using a counter and the tag attribute of Treeview items, but it would return the number as a <code>NoneType</code>. I also tried using the value attribute, but it returned the same problem.</p>

<p>For information, I have read through many sites and a few questions on here, but none (that I have found) answer what I need.</p>

<p>Any help would be greatly appreciated, thank you for taking the time to read.</p>

<p>You can call the <a href="https://docs.python.org/3/library/tkinter.ttk.html#tkinter.ttk.Treeview.selection" rel="nofollow">selection</a> method to get a list of all selected items:</p>

<pre><code>selected_items = self.tree.selection()
</code></pre>

python tkinter treeview ttk