          self._canvas.tag_bind(self._canvas.image_id, "<Button-1>", self._on_mouse_click)
          self._canvas.tag_bind(self._canvas.image_id, "<B1-Motion>", self._on_mouse_drag)
          logger.debug("Bound mouse events")
  
      def _set_key_bindings(self) -> None:
          # TODO set bind location for GUI
          """ Set the keyboard bindings.
  
          Up/Down/Left/Right: Moves image
          +/-: Zooms image
          ctrl+s: Save
 
</s> remove             widget.configure(image=get_images().previewoutput[1])
 </s> add             widget.configure(image=self._preview.image) </s> remove         Parameters
        ----------
        event: :class:`tkinter.Event`
            The resize event object
        """
        logger.trace("Resizing preview image")  # type:ignore
        framesize: Optional[Tuple[int, int]] = (event.width, event.height)
        # Sometimes image is resized before frame is drawn
        framesize = None if framesize == (1, 1) else framesize
        get_images().resize_image(self.name, framesize)
        self.reload()

    def reload(self) -> None:
        """ Reload the preview image """
        logger.trace("Reloading preview image")  # type:ignore
        self.previewimage = get_images().previewtrain[self.name][1]
        self.canvas.itemconfig(self.imgcanvas, image=self.previewimage)

    def save_preview(self, location: str) -> None:
        """ Save the figure to file.

        Parameters
        ----------
        location: str
            The full path to the location to save the preview image
        """
        filename = self.name
        now = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
        filename = os.path.join(location, f"{filename}_{now}.png")
        cast("Image.Image", get_images().previewtrain[self.name][0]).save(filename)
        logger.debug("Saved preview to %s", filename)
        print(f"Saved preview to {filename}")
 </s> add         self._display.save(location)
    def _set_key_bindings(self, is_standalone: bool) -> None:
          self._canvas.tag_bind(self._canvas.image_id, "<Button-1>", self._on_mouse_click)
          self._canvas.tag_bind(self._canvas.image_id, "<B1-Motion>", self._on_mouse_drag)
          logger.debug("Bound mouse events")
  
    def _set_key_bindings(self, is_standalone: bool) -> None:
    def _set_key_bindings(self, is_standalone: bool) -> None:
          """ Set the keyboard bindings.
  
          Up/Down/Left/Right: Moves image
          +/-: Zooms image
          ctrl+s: Save
keep keep keep keep replace replace keep keep keep keep keep
 GUI - Preview updates
  - Training preview. Embed preview pop-out window
  - Bugfix - convert/extract previews 
lib/training/preview_tk.py