title: ttk Treeview: How to select a row?
body: <p>This must be something simple I'm missing, but I can't seem to figure out how to set the selection row in a Treeview using the <code>selection_set</code> method.  I am confused by the ttk documentation which sometimes refers to <em><code>items</code></em> and other times to <em><code>iid</code></em> for method arguments.  When I insert a row into the <code>Treeview</code>, am I not creating an item which I give the handle <code>iid</code>?</p>
  <pre><code>import Tkinter as Tk
  import ttk
  
  root = Tk.Tk()
  tree = ttk.Treeview(root, displaycolumns='#all')
  tree[&quot;columns&quot;]=(&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;)
  tree.column(&quot;#0&quot;, width=70)
  tree.column(&quot;1&quot;, width=70, anchor=Tk.CENTER)
  tree.column(&quot;2&quot;, width=50, anchor=Tk.CENTER)
  tree.column(&quot;3&quot;, width=50, anchor=Tk.CENTER)
  tree.column(&quot;4&quot;, width=70, anchor=Tk.CENTER)
  tree.heading(&quot;1&quot;, text=&quot;Column 1&quot;)
  tree.heading(&quot;2&quot;, text=&quot;Column 2&quot;)
  tree.heading(&quot;3&quot;, text=&quot;Column 3&quot;)
  tree.heading(&quot;4&quot;, text=&quot;Column 4&quot;)
  id2 = []
  count = 0
  item_list = ['A', 'B', 'C', 'D']
  for item in item_list:
      id = tree.insert(&quot;&quot;, count, iid='Row %s'%count, text=item, values=('1', '2', '3', '4'))
      id2.append(id)
      count += 1
  
  tree.selection_set('Row 0') # Doesn't work -- returns &quot;_tkinter.TclError:  Item Row not found&quot;
  tree.pack(fill=Tk.BOTH, expand=1, side=Tk.RIGHT,padx=50)
  
  Tk.mainloop()
  </code></pre>
  <p>Traceback:</p>
  <pre class="lang-none prettyprint-override"><code>Traceback (most recent call last):
    File &quot;python-ttk-treeview-how-to-select-a-row.py&quot;, line 28, in &lt;module&gt;
      tree.selection_set('Row 0')  # Doesn't work -- returns &quot;_tkinter.TclError:  Item Row not found&quot;
    File &quot;C:\Python\lib\lib-tk\ttk.py&quot;, line 1402, in selection_set
      self.selection(&quot;set&quot;, items)
    File &quot;C:\Python\lib\lib-tk\ttk.py&quot;, line 1397, in selection
      return self.tk.call(self._w, &quot;selection&quot;, selop, items)
  _tkinter.TclError: Item Row not found
  </code></pre>