          ''' Builds the GUI '''
          self.arguments = arguments
          self.root.title('faceswap.py')
          self.menu()
          notebook = ttk.Notebook(self.root)
          notebook.pack(fill=tk.BOTH, expand=True)
  
          # extract, train and convert are explicitly stated to ensure they are always displayed in the same order
          for command in ('extract', 'train', 'convert'):
              title = command.title()
 
</s> remove         # extract, train and convert are explicitly stated to ensure they are always displayed in the same order
 </s> add         # Commands explicitly stated to ensure consistent ordering </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') </s> remove             title = command.title()
            page = ttk.Frame(notebook)
            
            self.add_left_frame(page, command)
            self.add_frame_seperator(page)
            opt_frame = self.add_right_frame(page)
            
            for option in self.opts[command]:
                self.build_tabs(option, opt_frame)
            
            notebook.add(page, text=title)

        self.root.mainloop()
 </s> add             commandtab = CommandTab(self, notebook, command)
            commandtab.build_tab() </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)
        notebook = ttk.Notebook(self.gui)
          ''' Builds the GUI '''
          self.arguments = arguments
          self.root.title('faceswap.py')
          self.menu()
        notebook = ttk.Notebook(self.gui)
          notebook.pack(fill=tk.BOTH, expand=True)
  
          # extract, train and convert are explicitly stated to ensure they are always displayed in the same order
          for command in ('extract', 'train', 'convert'):
              title = command.title()
keep keep keep keep 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