title: Using Draw in PIL/TKinter
body: <p>I'm trying to use PIL and Tkinter to make some custom image processing software.  I want to use the mouse to select a region of interest in the image, grab those pixel values, and pass it to scipy/numpy for some number crunching and possible PIL for some more image editing.</p>
  
  <p>So far I have a RegionOfInterest class:</p>
  
  <pre><code>class RegionOfInterest:
      def __init__(self,image,boundingBox):
          #take bounding box, draw an oval on the image, save boundingBox locally                                                                                                                                
          self.box = boundingBox
          self.avgInt = 0
          self.draw = ImageDraw.Draw(image)
          self.draw.rectangle(boundingBox,outline='white')
  
      def capture(self):
          region_to_capture = image.crop(box)
          region_to_capture.save('output.jpg')
  </code></pre>
  
  <p>which takes a PIL image object and a boundingBox (with a capture method for cropping and saving the image). This gets called by a draw function:</p>
  
  <pre><code>def draw(event):
      global image
      global region
      global listOfRegions
      mouse_X = event.x
      mouse_Y = event.y
      region.append(mouse_X)
      region.append(mouse_Y)
      if len(region) == 4:
          roi = RegionOfInterest(image,region)
          listOfRegions.append(roi)
          canvas.update()
          roi.findPixels()
          roi.calcIntensity()
          region = []
  </code></pre>
  
  <p>Which is in turn called by a control-click through Tkinter</p>
  
  <pre><code>mouse_X = 0
  mouse_Y = 0
  region = []
  listOfRegions = []
  
  image = Image.open('test.jpg')
  image = image.convert('L')
  imPix = image.load()
  canvas = Tkinter.Canvas(window, width=image.size[0], height=image.size[1])
  canvas.pack()
  image_tk = ImageTk.PhotoImage(image)
  canvas.create_image(image.size[0]//2, image.size[1]//2, image=image_tk)
  
  window.bind("&lt;Control-Button-1&gt;", draw)
  window.bind("&lt;Control-space&gt;", lambda e: nextFrame(sequence_object=sequence,event=e))
  Tkinter.mainloop()
  </code></pre>
  
  <p>My biggest problem at the moment is that when I draw the rectangle (way back in RegionOfIntereste.<strong>init</strong>()), the rectangles don't show up!</p>
  
  <p>Any advice on how to get this to work?  Perhaps any suggestions for resources on learning how to interface tkinter/pil better?</p>