title: Infinite loop or no action when binding <<ListboxSelect>>
body: <p>I am trying to use changes in the selection of a tkinter Listbox to plot on a matplotlib figure. I have bound ListboxSelect to a callback function that should grab the rows selected in the Listbox. It then takes the row information and plots it in an already existing matplotlib plot. My problem is that, depending if the last line of the callback function is commented out, the callback function infinitely loops or only triggers once despite changes to the Listbox selection. How do I get it to only perform the callback function one time per change of the Listbox selection and then do it every time there is a change?</p>
  
  <pre><code>from tkinter import *
  import matplotlib.pyplot as plt
  from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
  
  root = Tk()
  root.title('Plotting Tool')
  root.minsize(640,480)
  
  scheduleWindow = Toplevel()
  scheduleWindow.title('Schedule')
  scheduleWindow.geometry("%dx%d%+d%+d" % (0, 400, 0, 100))
  
  scheduleList = Listbox(scheduleWindow, selectmode = EXTENDED)
  
  x = []
  
  for i in range(0,21):
      scheduleList.insert(END, i)
      x.append(i)
  
  scheduleList.pack(expand=True, fill = Y)
  
  fig = plt.figure(tight_layout=True)
  ax = fig.add_subplot(111, autoscale_on = True)
  ax.set_xlim(0,20)
  
  y = [0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765]
  
  ax.plot(x,y)
  
  canvas = FigureCanvasTkAgg(fig,root)
  canvas.get_tk_widget().pack(side = TOP, fill = BOTH, expand = True)
  canvas.show()
  
  def grayzone():
      print(scheduleList.curselection())
      try:
          gray
      except:
          pass
      else:
          #clearing function to be added later
  
      if scheduleList.curselection() == ():
          gray = ax.axvspan( 0, 0,ymin=0, ymax=1,facecolor='gray',alpha=0.25)
  
      else:
          gray = ax.axvspan( scheduleList.curselection()[0], scheduleList.curselection()[-1],ymin=0, ymax=1,facecolor='gray',alpha=0.25)
  
      canvas.show()
      #scheduleList.bind('&lt;&lt;ListboxSelect&gt;&gt;', grayzone())
  
  scheduleList.bind('&lt;&lt;ListboxSelect&gt;&gt;', grayzone())
  </code></pre>