  
  # Build the Right Frame Options
      def build_tabs(self, option, page):
          ''' Build the correct control type for the option passed through '''
          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)
  
      @staticmethod
      def build_control_frame(page):
          ''' Build the frame to hold the control '''
          frame = tk.Frame(page)
 
</s> remove     def build_tabs(self, option, page):
 </s> add     def build_tabs(self, option, option_frame): </s> remove     @staticmethod
    def build_control_frame(page):
 </s> add         self.build_control_label(ctlframe, ctltitle)
        option['value'] = self.build_control(ctlframe, ctl, dflt, ctlhelp, choices, sysbrowser)

    def build_control_frame(self, option_frame): </s> remove        
        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)
 </s> add         self.task = FaceswapControl() </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         frame = tk.Frame(page)
 </s> add         frame = tk.Frame(option_frame)
        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
  
  # Build the Right Frame Options
      def build_tabs(self, option, page):
          ''' Build the correct control type for the option passed through '''
        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
        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
        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
        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
        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
        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
        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
        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
        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
        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
        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
        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
        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
        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
        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
  
      @staticmethod
      def build_control_frame(page):
          ''' Build the frame to hold the control '''
          frame = tk.Frame(page)
keep keep keep keep 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