code: def attach(self, canvas):
          
          super(PanZoom, self).attach(canvas)
          canvas.panzoom = self
  
          canvas.transforms.add_on_gpu([self._translate, self._scale])
          # Add the variable declarations.
          vs = ('uniform vec2 {};\n'.format(self.pan_var_name) +
                'uniform vec2 {};\n'.format(self.zoom_var_name))
          canvas.inserter.insert_vert(vs, 'header')
  
          canvas.connect(self.on_resize)
          canvas.connect(self.on_mouse_move)
          canvas.connect(self.on_touch)
          canvas.connect(self.on_key_press)
  
          if self.enable_mouse_wheel:
              canvas.connect(self.on_mouse_wheel)
  
          self._set_canvas_aspect()
docs: Attach this interact to a canvas.