title: How to use a <ComboboxSelected> virtual event with tkinter
body: <p>I am using a tkk.Combobox themed widget in Python 3.5.2.  I want an action to happen when a value is selected.</p>
  
  <p>In the Python <a href="https://docs.python.org/3/library/tkinter.ttk.html#virtual-events" rel="noreferrer">docs</a>, it says:</p>
  
  <blockquote>
    <p>The combobox widgets generates a <code>&lt;&lt;ComboboxSelected&gt;&gt;</code> virtual event when the user selects an element from the list of values.</p>
  </blockquote>
  
  <p>Here on the Stack, there are a number of answers (<a href="https://stackoverflow.com/a/17757533/3380131">1</a>, <a href="https://stackoverflow.com/q/5235998/3380131">2</a>, etc) that show how to bind the event:</p>
  
  <pre><code>cbox.bind("&lt;&lt;ComboboxSelected&gt;&gt;", function)
  </code></pre>
  
  <p>However, I can't make it work.  Here's a very simple example demonstrating my non-functioning attempt:</p>
  
  <pre><code>import tkinter as tk
  from tkinter import ttk
  
  tkwindow = tk.Tk()
  
  cbox = ttk.Combobox(tkwindow, values=[1,2,3], state='readonly')
  cbox.grid(column=0, row=0)
  
  cbox.bind("&lt;&lt;ComboboxSelected&gt;&gt;", print("Selected!"))
  
  tkwindow.mainloop()
  </code></pre>
  
  <p>I get one instance of "Selected!" immediately when I run this code, even without clicking anything.  But nothing happens when I actually select something in the combobox.</p>
  
  <p>I'm using IDLE in Windows 7, in case it makes a difference.</p>
  
  <p>What am I missing?</p>