title: Python (Tkinter) - canvas for-loop color change
body: <p>I generated a grid using a for-loop in Tkinter, but want to know how I would be able to bind an on-click function to  such that when I click on each individual generated rectangle, the rectangle will change color.</p>
  
  <pre><code>from Tkinter import *
  
  master = Tk()
  
  def rowgen(row, col):
      for i in range(row):
          for j in range(col):
              w.create_rectangle(25+50*i, 25+50*j, 50+50*i, 50+50*j, fill="green")
  
  w = Canvas(master, width=225, height=225)
  w.pack()
  rowgen(4, 4)
  
  
  master.resizable(0,0)
  mainloop()
  </code></pre>
  
  <p>I'm thinking that I have to first iterate through another for-loop to make an event, where if I click within these coordinates, I'd reconfig the color of one of the rectangles.</p>