      def add_child(self) -> None:
          """ Add the preview label child """
          logger.debug("Adding child")
          preview = self.subnotebook_add_page(self.tabname, widget=None)
          lblpreview = ttk.Label(preview, image=get_images().previewoutput[1])
          lblpreview.pack(side=tk.TOP, anchor=tk.NW)
          Tooltip(lblpreview, text=self.helptext, wrap_length=200)
  
      def update_child(self) -> None:
          """ Update the preview image on the label """
 
</s> remove             widget.configure(image=get_images().previewoutput[1])
 </s> add             widget.configure(image=self._preview.image) </s> remove         logger.trace("Displaying preview")  # type:ignore
        sortednames = sorted(list(get_images().previewtrain.keys()))
        existing = self.subnotebook_get_titles_ids()
        should_update = self.update_preview.get()

        for name in sortednames:
            if name not in existing:
                self.add_child(name)
            elif should_update:
                tab_id = existing[name]
                self.update_child(tab_id, name)

        if should_update:
            self.update_preview.set(False)

    def add_child(self, name: str) -> None:
        """ Add the preview canvas child

        Parameters
        ----------
        name: str
            The name of the notebook tab to add
        """
        logger.debug("Adding child")
        preview = PreviewTrainCanvas(self.subnotebook, name)
        preview = self.subnotebook_add_page(name, widget=preview)
        Tooltip(preview, text=self.helptext, wrap_length=200)
        self.vars["modified"].set(get_images().previewtrain[name][2])

    def update_child(self, tab_id: int, name: str) -> None:
        """ Update the preview canvas
 </s> add         if self.subnotebook.children:
            return </s> remove         Parameters
        ----------
        tab_id: int
            The index of the tab to update
        name: str
            The name of the tab to update
        """
        logger.debug("Updating preview")
        if self.vars["modified"].get() != get_images().previewtrain[name][2]:
            self.vars["modified"].set(get_images().previewtrain[name][2])
            widget = self.subnotebook_page_from_id(tab_id)
            widget.reload()
 </s> add         logger.debug("Displaying preview")
        self._display = PreviewTk(self._preview.buffer, self.subnotebook, self.optsframe, None)
        self.subnotebook_add_page(self.tabname, widget=self._display.master_frame) </s> remove         for preview in self.subnotebook.children.values():
            preview.save_preview(location)


class PreviewTrainCanvas(ttk.Frame):  # pylint: disable=too-many-ancestors
    """ Canvas to hold a training preview image

    Parameters
    ----------
    parent: :class:`tkinter.ttk.Notebook`
        The notebook that the training image canvas belongs to
    previewname: str
        The name of the preview image displayed in the canvas
    """
    def __init__(self, parent: ttk.Notebook, previewname: str) -> None:
        logger.debug("Initializing %s: (previewname: '%s')", self.__class__.__name__, previewname)
        ttk.Frame.__init__(self, parent)

        self.name = previewname
        get_images().resize_image(self.name, None)
        self.previewimage = get_images().previewtrain[self.name][1]

        self.canvas = tk.Canvas(self, bd=0, highlightthickness=0)
        self.canvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
        self.imgcanvas = self.canvas.create_image(0,
                                                  0,
                                                  image=self.previewimage,
                                                  anchor=tk.NW)
        self.bind("<Configure>", self.resize)
        logger.debug("Initialized %s:", self.__class__.__name__)

    def resize(self, event: tk.Event) -> None:
        """  Resize the image to fit the frame, maintaining aspect ratio
 </s> add 
        lblpreview = ttk.Label(preview, image=self._preview.image)
      def add_child(self) -> None:
          """ Add the preview label child """
          logger.debug("Adding child")
          preview = self.subnotebook_add_page(self.tabname, widget=None)
        lblpreview = ttk.Label(preview, image=self._preview.image)
          lblpreview.pack(side=tk.TOP, anchor=tk.NW)
          Tooltip(lblpreview, text=self.helptext, wrap_length=200)
  
      def update_child(self) -> None:
          """ Update the preview image on the label """
keep keep keep keep replace keep keep keep keep keep
 GUI - Preview updates
  - Training preview. Embed preview pop-out window
  - Bugfix - convert/extract previews 
lib/gui/display_command.py