  import sys
  from threading import Thread
  import tkinter as tk
  
  from tkinter import ttk
  from tkinter import filedialog
  
  from lib.cli import FullPaths
  from lib.Serializer import JSONSerializer
  
  class TKGui(object):
 
</s> remove from threading import Thread
import tkinter as tk
 </s> add  </s> remove class TKGui(object):
 </s> add # Users without tkinter distrubtion packages or without an X-Console will error out
# importing tkinter. Therefore run a check on these and only import if required 
tk = None
ttk = None
filedialog = None

def import_tkinter(command):
    ''' Perform checks when importing tkinter module to ensure that GUI will load '''
    global tk
    global ttk
    global filedialog
    try:
        import tkinter
        from tkinter import ttk
        from tkinter import filedialog
        tk = tkinter
    except ImportError:
        if 'gui' in command:
            print(  'It looks like TkInter isn''t installed for your OS, so the GUI has been '
                    'disabled. To enable the GUI please install the TkInter application.\n'
                    'You can try:\n'
                    '  Windows/macOS:      Install ActiveTcl Community Edition from '
                    'www.activestate.com\n'
                    '  Ubuntu/Mint/Debian: sudo apt install python3-tk\n'
                    '  Arch:               sudo pacman -S tk\n'
                    '  CentOS/Redhat:      sudo yum install tkinter\n'
                    '  Fedora:             sudo dnf install python3-tkinter\n')
        return False
    return True    

def check_display(command):
    # Check whether there is a display to output the GUI '''
    if not environ.get('DISPLAY', None):
        if 'gui' in command:
            print ('Could not detect a display. The GUI has been disabled')
        return False
    return True

class FaceswapGui(object): </s> remove     def __init__(self, subparser, subparsers, parser, command, description='default'):
        self.root = tk.Tk()
 </s> add     def __init__(self, options, parser):
        self.gui = tk.Tk()
        self.opts = options </s> remove             options = [option for option in self.opts[command]]
 </s> add             options = [opt for opt in self.opts[command]] </s> remove             options = [option for options in self.opts.values() for option in options]
 </s> add             options = [opt for opts in self.opts.values() for opt in opts]
from os import environ, path
from threading import Thread
  import sys
  from threading import Thread
  import tkinter as tk
  
from os import environ, path
from threading import Thread
from os import environ, path
from threading import Thread
  
  from lib.cli import FullPaths
  from lib.Serializer import JSONSerializer
  
  class TKGui(object):
keep keep keep keep 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