title: Tkinter - Bind lambda to rectangle on canvas
body: <pre><code>...
  def bind(self):
      for x_num in range(10):
          for y_num in range(10):
              pixel = pix_array[x_num][y_num]
              self.canvas.tag_bind(pixel, "&lt;Enter&gt;", (lambda event, x=x_num, y=y_num: self.on_enter(x,y)))
  ...  
  def on_enter(self, event, x, y):
      pass
  </code></pre>
  
  <p>Where <code>canvas</code> is a canvas fully initialized on a tkinter window <code>master</code>. Upon running this code, this error is thrown:</p>
  
  <pre><code>self.canvas.tag_bind(self.canvas.tag_bind(pixel, "&lt;Enter&gt;", (lambda event, x=x_num, y=y_num: self.on_enter(x,y)))
  File "C:\(path removed)\Python\Python36-32\lib\tkinter\__init__.py", line 2447, in tag_bind
  sequence, func, add)
  File "C:\(path removed)\Python\Python36-32\lib\tkinter\__init__.py", line 1200, in _bind
  self.tk.call(what + (sequence, cmd))
  _tkinter.TclError: wrong # args: should be ".!canvas bind tagOrId ?sequence? ?command?"
  </code></pre>
  
  <p>Why is this error being thrown?</p>
  
  <p>I can post more of the code if it is important, but it seems as the though the error is in the way I'm calling this function, or being caused by the way I understand it.</p>
  
  <p>EDIT: Cause was <code>pix_array</code> not having assigned values at this point in the code.</p>