code: def zoom_leftup(self, event=None):
          
          if self.zoom_ini is None:
              return
  
          ini_x, ini_y, ini_xd, ini_yd = self.zoom_ini
          try:
              dx = abs(ini_x - event.x)
              dy = abs(ini_y - event.y)
          except:
              dx, dy = 0, 0
          t0 = time.time()
          self.rbbox = None
          self.zoom_ini = None
          if (dx > 3) and (dy > 3) and (t0-self.mouse_uptime)>0.1:
              self.mouse_uptime = t0
              zlims, tlims = {}, {}
              ax =  self.axes
              xmin, xmax = ax.get_xlim()
              ymin, ymax = ax.get_ylim()
  
              zlims[ax] = [xmin, xmax, ymin, ymax]
  
              if len(self.conf.zoom_lims) == 0:
                  self.conf.zoom_lims.append(zlims)
  
  
              ax_inv = ax.transData.inverted
              try:
                  x1, y1 = ax_inv().transform((event.x, event.y))
              except:
                  x1, y1 = self.x_lastmove, self.y_lastmove
              try:
                  x0, y0 = ax_inv().transform((ini_x, ini_y))
              except:
                  x0, y0 = ini_xd, ini_yd
  
              tlims[ax] = [int(round(min(x0, x1))), int(round(max(x0, x1))),
                           int(round(min(y0, y1))), int(round(max(y0, y1)))]
              self.conf.zoom_lims.append(tlims)
              # now apply limits:
              self.set_viewlimits()
              if callable(self.zoom_callback):
                  self.zoom_callback(wid=self.GetId(), limits=tlims[ax])
docs: leftup event handler for zoom mode  in images