title: Changing the colour on click of a tkinter rectangle on click in python
body: <p>So I have this code which draws a simple rectangle:</p>
  
  <pre><code>from tkinter import *
  
  root = Tk()
  canvas = Canvas(root, width = 500, height = 500)
  canvas.pack()
  
  canvas.create_rectangle(100, 100, 400, 400, fill='black')
  
  
  mainloop()
  </code></pre>
  
  <p>Now I've been looking everywhere, and can't seem to find a way to change the fill colour at all, and ideally I'd like to be able to do this on click.</p>
  
  <p>I'm actually going to be using this to change the colour of hexagons generated by a function I wrote that works fine using</p>
  
  <pre><code>create_polygon()
  </code></pre>
  
  <p>but I imagine it'll work identically with a rectangle.</p>
  
  <p>I realise the code may need to be completely restructured.</p>