  
          for cmd, opts in opts.items():
              self.set_command_args(cmd, opts)
  
          if command:
              if command in self.command_tabs:
                  self.command_notebook.select(self.command_tabs[command])
              else:
                  self.command_notebook.select(self.command_tabs["tools"])
                  self.command_notebook.tools_notebook.select(self.tools_command_tabs[command])
          self.add_to_recent(filename, command)
          logger.debug("Loaded config: (command: '%s', filename: '%s')", command, filename)
  
      def get_command_options(self, cfg, command):
          """ return the saved options for the requested
              command, if not loading global options """
          opts = cfg.get(command, None)
          retval = {command: opts}
          if not opts:
              self.tk_vars["consoleclear"].set(True)
              print("No {} section found in file".format(command))
              logger.info("No  %s section found in file", command)
              retval = None
          logger.debug(retval)
          return retval
  
      def set_command_args(self, command, options):
          """ Pass the saved config items back to the CliOptions """
          if not options:
              return
 
</s> remove     def set_command_args(self, command, options):
        """ Pass the saved config items back to the CliOptions """
        if not options:
            return
        for srcopt, srcval in options.items():
            optvar = self.cli_opts.get_one_option_variable(command, srcopt)
            if not optvar:
                continue
            optvar.set(srcval)

    def save(self, command=None):
        """ Save the current GUI state to a config file in json format """
        logger.debug("Saving config: (command: '%s')", command)
        cfgfile = FileHandler("save", "config").retfile
        if not cfgfile:
            return
        filename = cfgfile.name
        cfgfile.close()
        cfg = self.cli_opts.get_option_values(command)
        self.serializer.save(filename, cfg)
        self.add_to_recent(filename, command)
        logger.debug("Saved config: (command: '%s', filename: '%s')", command, filename)

    def add_to_recent(self, filename, command):
        """ Add to recent files """
        recent_filename = os.path.join(self.pathcache, ".recent.json")
        logger.debug("Adding to recent files '%s': (%s, %s)", recent_filename, filename, command)
        if not os.path.exists(recent_filename) or os.path.getsize(recent_filename) == 0:
            recent_files = list()
        else:
            recent_files = self.serializer.load(recent_filename)
        logger.debug("Initial recent files: %s", recent_files)
        filenames = [recent[0] for recent in recent_files]
        if filename in filenames:
            idx = filenames.index(filename)
            del recent_files[idx]
        recent_files.insert(0, (filename, command))
        recent_files = recent_files[:20]
        logger.debug("Final recent files: %s", recent_files)
        self.serializer.save(recent_filename, recent_files)


class ContextMenu(tk.Menu):  # pylint: disable=too-many-ancestors
    """ Pop up menu """
    def __init__(self, widget):
        logger.debug("Initializing %s: (widget_class: '%s')",
                     self.__class__.__name__, widget.winfo_class())
        super().__init__(tearoff=0)
        self.widget = widget
        self.standard_actions()
        logger.debug("Initialized %s", self.__class__.__name__)
 </s> add  </s> remove     def load(self, command=None, filename=None):
        """ Pop up load dialog for a saved config file """
        logger.debug("Loading config: (command: '%s')", command)
        if filename:
            if not os.path.isfile(filename):
                msg = "File does not exist: '{}'".format(filename)
                logger.error(msg)
                return
            cfg = self.serializer.load(filename)
        else:
            cfgfile = FileHandler("open", "config").retfile
            if not cfgfile:
                return
            filename = cfgfile.name
            cfgfile.close()
            cfg = self.serializer.load(filename)

        if not command and len(cfg.keys()) == 1:
            command = list(cfg.keys())[0]

        opts = self.get_command_options(cfg, command) if command else cfg
        if not opts:
            return
 </s> add     def set_root_title(self, text=None):
        """ Set the main title text for Faceswap. </s> remove         for cmd, opts in opts.items():
            self.set_command_args(cmd, opts)
 </s> add         The title will always begin with 'Faceswap.py'. Additional text can be appended. </s> remove     def set_kwargs(self, filetype, command, action, variable=None):
        """ Generate the required kwargs for the requested browser """
        logger.debug("Setting Kwargs: (filetype: '%s', command: '%s': action: '%s', "
                     "variable: '%s')", filetype, command, action, variable)
 </s> add     def _set_kwargs(self, title, initialdir, filetype, command, action, variable=None):
        """ Generate the required kwargs for the requested file dialog browser.

        Returns
        -------
        dict:
            The key word arguments for the file dialog to be launched
        """
        logger.debug("Setting Kwargs: (title: %s, initialdir: %s, filetype: '%s', "
                     "command: '%s': action: '%s', variable: '%s')",
                     title, initialdir, filetype, command, action, variable) </s> remove         logger.debug("command: '%s', ctl_dict: '%s'", command, ctl_dict)
 </s> add         logger.debug("command: '%s', ctl_dict: %s", command, ctl_dict)
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
  
          for cmd, opts in opts.items():
              self.set_command_args(cmd, opts)
  
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
        Parameters
        ----------
        text: str, optional
            Additional text to be appended to the GUI title bar. Default: ``None``
        """
        title = "Faceswap.py"
        title += " - {}".format(text) if text is not None and text else ""
        self.root.title(title)
  
      def set_command_args(self, command, options):
          """ Pass the saved config items back to the CliOptions """
          if not options:
              return
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 GUI Updates (#940)

* lib.gui: Update icons
* tools.cli: Add video filetype flag to mask input
* lib.gui.popup_configure: Refresh GUI on config save
* lib.gui._config: Add Icon size and load last session options
* lib.gui.control_helper - Add control modification tracking
* lib.gui - Add Projects and Last Session
- Main root title handled by projects
- Add Hotkeys
- Create projects module
- split fsw and fst filetypes
- Add last_session saving

* lib.project
- Documentation
- Ask confirm on closing unsaved project
-Fixups

* Track model folder changes
- Shuffle some globals
- Activate System Verbosity for GUI

* lib.gui.utils - Documentation and clean up
- lib.gui.custom_widgets - Create and document

* Add GUI config option to disable auto loading model stats 
lib/gui/utils.py