title: Tkinter - Run Event Function Upon Listbox Selection
body: <p>I have a ListboxSelect event binding to my listbox, lb. I am using selection_set to select an item in the listbox, but the binded function doesn't run. How can I make the function run when I select an item in the listbox using selection_set as well as when it is clicked?</p>
  
  <pre><code>import tkinter as tk
  
  class SampleApp(tk.Tk):
      def __init__(self, *args, **kwargs):
          tk.Tk.__init__(self, *args, **kwargs)
          self.lb = tk.Listbox(self)
  
          for x in range(20):
              self.lb.insert("end", x)
  
          self.lb.bind("&lt;&lt;ListboxSelect&gt;&gt;", self.OnSelect)
  
          self.lb.pack(side="top", fill="both", expand=True)
  
  
      def OnSelect(self, event):
          print(event.widget.get(event.widget.curselection()[0]))
          self.lb.selection_set(10)
  
  
  if __name__ == "__main__":
      app = SampleApp()
      app.mainloop()
  </code></pre>