code: def canvas_changed_cb(self, canvas, whence):
          
          self.logger.debug("root canvas changed, whence=%d" % (whence))
  
          # special check for whether image changed out from under us in
          # a shared canvas scenario
          try:
              # See if there is an image on the canvas
              canvas_img = self.canvas.get_object_by_tag(self._canvas_img_tag)
              if self._imgobj is not canvas_img:
                  self._imgobj = canvas_img
                  self._imgobj.add_callback('image-set', self._image_set_cb)
  
                  self._image_set_cb(canvas_img, canvas_img.get_image())
  
          except KeyError:
              self._imgobj = None
  
          self.redraw(whence=whence)
docs: Handle callback for when canvas has changed.