          self.helptext = tk.StringVar()
          self.statustext = tk.StringVar()
          self.serializer = JSONSerializer
          self.filetypes=(('Faceswap files', '*.fsw'),  ('All files', '*.*'))
         
          self.parse_arguments(description, subparser, command)
  
      def bad_args(self, args):
          self.parser.print_help()
          exit(0)
  
      def extract_options(self, subparsers):
          ''' Extract the existing ArgParse Options '''
          options = {command: subparsers[command].argument_list + subparsers[command].optional_arguments for command in subparsers.keys()}
          for command in options.values():
              for option in command:
                  option['control_title'] = self.set_control_title(option.get('opts',''))
                  option['control_type'] = self.set_control_type(option)
          return options
  
      @staticmethod
      def set_control_title(opts):
          ''' Take the option switch and format it nicely '''
          ctl_title = opts[0]
          if len(opts) == 2:
              ctl_title = opts[1]
          ctl_title = ctl_title.replace('-',' ').replace('_',' ')
          ctl_title = ctl_title.title().strip()
          return ctl_title
   
      @staticmethod
      def set_control_type(option):
          ''' Set what control type we should use for an option based on existence of various variables '''
          if option.get('dest', '') == 'alignments_path':
              ctl_type = 'filechooser'
          elif option.get('action', '') == FullPaths:
              ctl_type = 'folderchooser'
          elif option.get('choices', '') != '':
              ctl_type = 'combobox'
          elif option.get('type', '') in (str, float, int):
              ctl_type = 'entrybox'
          elif option.get('action', '') == 'store_true':
              ctl_type = 'checkbox'
          return ctl_type
  
      def parse_arguments(self, description, subparser, command):
          parser = subparser.add_parser(
              command,
              help="This Launches a GUI for Faceswap.",
              description=description,
              epilog="Questions and feedback: \
              https://github.com/deepfakes/faceswap-playground"
          )
          parser.set_defaults(func=self.process)
  
      def process(self, arguments):
          ''' Builds the GUI '''
          self.arguments = arguments
          self.root.title('faceswap.py')
 
</s> remove         ctl_type = option['control_type']
        ctl_title = option['control_title']
        ctl_help = ' '.join(option.get('help', '').split())
        ctl_help = '. '.join(i.capitalize() for i in ctl_help.split('. '))
        ctl_help = ctl_title + ' - ' + ctl_help
        ctl_frame = self.build_control_frame(page)
        self.build_control_label(ctl_frame, ctl_title)
        if ctl_type == 'combobox':
            option['value'] = self.build_combobox(ctl_frame, ctl_help, option.get('default',''), option['choices'])
        if ctl_type == 'checkbox':
            option['value'] = self.build_checkbox(ctl_frame, ctl_help, option.get('default', False), ctl_title)
        if ctl_type == 'entrybox':
            option['value'] = self.build_entrybox(ctl_frame, ctl_help, option.get('default',''), None)
        if ctl_type in ('filechooser', 'folderchooser'):
            option['value'] = self.build_entrybox(ctl_frame, ctl_help, option.get('default',''), ctl_type)
 </s> add         ctl = option['control']
        ctltitle = option['control_title']
        sysbrowser = option['filesystem_browser']
        ctlhelp = ' '.join(option.get('help', '').split())
        ctlhelp = '. '.join(i.capitalize() for i in ctlhelp.split('. '))
        ctlhelp = ctltitle + ' - ' + ctlhelp
        ctlframe = self.build_control_frame(option_frame)
        
        dflt = option.get('default', False) if ctl == tk.Checkbutton else option.get('default', '')
        choices = option['choices'] if ctl == ttk.Combobox else None </s> remove     def build_tabs(self, option, page):
 </s> add     def build_tabs(self, option, option_frame): </s> remove         self.opts = self.extract_options(subparsers)
        self.icofolder = tk.PhotoImage(file='icons/open_folder.png')
        self.icofile = tk.PhotoImage(file='icons/open_file.png')
        self.icosave = tk.PhotoImage(file='icons/save.png')
        self.icoreset = tk.PhotoImage(file='icons/reset.png')
        self.icoclear = tk.PhotoImage(file='icons/clear.png')
 </s> add         
        pathscript = path.realpath(path.dirname(sys.argv[0]))
        pathicons = path.join(pathscript, 'icons')
        self.icofolder = tk.PhotoImage(file=path.join(pathicons,'open_folder.png'))
        self.icoload = tk.PhotoImage(file=path.join(pathicons,'open_file.png'))
        self.icosave = tk.PhotoImage(file=path.join(pathicons,'save.png'))
        self.icoreset = tk.PhotoImage(file=path.join(pathicons,'reset.png'))
        self.icoclear = tk.PhotoImage(file=path.join(pathicons,'clear.png'))
 </s> remove         optlist = ['faceswap.py', command]
        for item in self.opts[command]:
            opt_value = str(item.get('value','').get())
            opt = item['opts'][0]
            if opt_value == 'False' or opt_value == '':
                continue
            elif opt_value == 'True':
                optlist.append(opt)
            else:
                optlist.extend((opt, opt_value))
        sys.argv = optlist
        process = Thread(target=self.launch_thread, args=(command,))
        process.start()

    def launch_thread(self, command):
        ''' Launch the script inside a subprocess to keep the GUI active '''
        title = command.capitalize()
        self.statustext.set('Running - {}'.format(title))
        self.parser.set_defaults(func=self.bad_args)
        arguments = self.parser.parse_args()
        arguments.func(arguments)
        self.statustext.set('Idle')
 </s> add         for option in self.gui.opts[self.command]:
            self.build_tabs(option, opt_frame) </s> remove     def process(self, arguments):
        ''' Builds the GUI '''
        self.arguments = arguments
        self.root.title('faceswap.py')
 </s> add     def build_gui(self):
        ''' Build the GUI '''
        self.gui.title('faceswap.py')
        self.task = FaceswapControl()
          self.helptext = tk.StringVar()
          self.statustext = tk.StringVar()
          self.serializer = JSONSerializer
          self.filetypes=(('Faceswap files', '*.fsw'),  ('All files', '*.*'))
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
        self.task = FaceswapControl()
  
      def process(self, arguments):
          ''' Builds the GUI '''
          self.arguments = arguments
          self.root.title('faceswap.py')
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 replace replace replace replace replace replace replace replace 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 v0.1.0a (#336)

* Code clean up

* Code refactor

* bugfix: Find paths to icons when launched from outside faceswap dir

* Bugfix: Disable GUI if TkInter app not available

* BugFix: Disable GUI if $DISPLAY not detected

* Minor code ammends

* Code Refactor

* DISPLAY check fix 
scripts/gui.py