예제 #1
0
def example2():

    if len(sys.argv) == 1:
        event, (fname) = sg.Window("File Opener").Layout(
            [[sg.Text('Documents to open')],
             [
                 sg.Text('Genome File', size=(12, 1)),
                 sg.InputText('~/Documents/uniquekmer/22.fa'),
                 sg.FileBrowse()
             ],
             [
                 sg.Text('Suffix Array', size=(12, 1)),
                 sg.InputText('~/Documents/uniquekmer/22.sa'),
                 sg.FileBrowse()
             ], [sg.CloseButton('Open'),
                 sg.CloseButton('Cancel')]]).Read()

    else:
        fname = sys.argv[1]

    if not fname:
        sg.Popup("Cancel", "No filename supplied")
        raise SystemExit("Cancelling: no filename supplied")

    for i in trange(1000):
        sg.OneLineProgressMeter(title="one line",
                                current_value=i + 1,
                                max_value=1000,
                                orientation='h',
                                key="progbar")

    print(event, fname)
def entryAF(length, width):
    entryLayout = [[sg.InputText('', size=(3, 1)) for i in range(length)]
                   for _ in range(width)
                   ] + [[sg.CloseButton("OK"),
                         sg.CloseButton("Cancel")]]

    entryWin = sg.Window("Input AF").Layout(entryLayout)
    button, values = entryWin.Read()
    return values
예제 #3
0
def webexPollBuilderGUI(t):
    return sg.Window("Webex Poll Builder").Layout(
        [[sg.Text("How long should the question last for?"),
          sg.Combo(t)],
         [sg.Text("Select the file with the question and answers.")],
         [sg.In(), sg.FileBrowse()],
         [sg.Text("Select the directory to save output file to.")],
         [sg.In(), sg.FolderBrowse()],
         [sg.Text("Enter filename. (Default is date)")], [sg.In()],
         [sg.CloseButton("OK"), sg.CloseButton("Cancel")]]).Read()
예제 #4
0
def gather_local_input_from_GUI():
    event, (fname, ) = (sg.Window("YTCompare").Layout([
        [sg.Text("Select your local music directory")],
        [sg.In(), sg.FolderBrowse()],
        [sg.CloseButton("Accept"),
         sg.CloseButton("Exit")],
    ]).Read())
    if event == "Exit":
        raise SystemExit("Closing")
    if not fname:
        sg.Popup("Closing", "No folder supplied")
        raise SystemExit("Closing: No folder supplied")

    return event, fname
def define_file():
    if len(sys.argv) == 1:
        event_define_file, (file_path, ) = sg.Window('My Script').Layout(
            [[sg.Text('Document to open')],
             [sg.In(size=(50, 10)), sg.FileBrowse()],
             [sg.CloseButton('Open'),
              sg.CloseButton('Cancel')]]).Read()
    else:
        file_path = sys.argv[1]
    if not file_path:
        sg.Popup("Cancel",
                 "No file path was supplied.",
                 background_color='#4a646c',
                 text_color='#ffffff')
        raise SystemExit("Cancelling - no file path was supplied.")
    return file_path
def show_text_file(file, file2=None):
    win_titel = "View Files"
    content = [None, None]
    files = []
    for i, fl in enumerate((file, file2)):
        if isinstance(fl, RmdFile):
            win_titel = "View Files: {}".format(fl.name)
            fl = fl.full_path
        try:
            with open(fl, "r", encoding=FILE_ENCODING) as fl_hdl:
                content[i] = fl_hdl.readlines()
            files.append(fl)
        except:
            pass

    if len(files)==0:
        return

    tabs = []
    for c, f in zip(content, files):
        if c is not None:
            tabs.append(sg.Tab("{}".format(path.split(f)[1]),
                    [[sg.Text("File: {}".format(f))],
                    [sg.Multiline(default_text="".join(c),
                        disabled=True, size=(80, 40))]]))

    layout = [[sg.TabGroup([tabs])],
              [sg.CloseButton("Close")]]
    window = sg.Window(win_titel, layout, finalize=True)
    window.refresh()
    while True:
        window.refresh()
        event, v = window.read()
        break
    window.close()
예제 #7
0
def getFile(inputfileArgument):
    if not inputfileArgument:
        event, values = sg.Window('ExcelToGraph').Layout(
            [[sg.Text('Excel File to open')], [sg.In(),
                                               sg.FileBrowse()],
             [sg.CloseButton('Open'),
              sg.CloseButton('Cancel')]]).Read()
        fname = values[0]
        # print(event, values)
    else:
        fname = inputfileArgument
    if not fname:
        sg.Popup("Cancel", "No filename supplied")
        raise SystemExit("Cancelling: no filename supplied")
    # print (fname)
    return fname
예제 #8
0
    def __init__(self):
        layout = [

            [gg.Text('BUSCAR ARQUIVO')],
            [gg.Input()], [gg.FileBrowse()],
            [gg.Ok()], [gg.Cancel()],
            [gg.Text('INSIRA OS DADOS A SEREM ANALISADOS.')],
            [gg.Text('Nome', size=(5, 0)), gg.Input(size=(50, 0), key='nome')],
            [gg.Text('Idade', size=(5, 0)), gg.Input(size=(50, 0), key='idade')],
            [gg.Text('Sexo', size=(5, 0)), gg.Input(size=(50, 0), key='sexo')],
            [gg.Text('CPF', size=(5, 0)), gg.Input(size=(50, 10), key='cpf')],
            [gg.Text('Nascimento', size=(5, 0)), gg.Input(size=(50, 0), key='data')],
            [gg.Text('Qual o seu estado civil?')],
            [gg.Checkbox('Casado', key='casado'), gg.Checkbox('Solteiro', key='solteiro')],
            [gg.Text('Selecione a escolaridade:')],
            [gg.Combo(['Ensino medio completo',   'Graduando', 'Ensino medio incompleto', 'Sem escolaridade'])],
            [gg.Button('Enviar Dados', size=(20, 0))],
            [gg.Output(size=(50, 20))],
            [gg.CloseButton('Cancelar', size=(20, 0))]




        ]
        self.janela = gg.Window("Analisador de Dados", size=(1024, 768)).layout(layout)
        gg.popup('Olá seja bem vindo!', 'Desenvolvido por Gustavo Carvalho', 'Clique em OK para continuar!')
예제 #9
0
def opm_popup(title, text, nrow=10, ncol=80, font=None):
    """Display Text Message in a Display Window

    Displays a text message in a multiline popup. Normally used for displaying help information, but any text string
    can be used.

    Parameters
    ----------
    title : str
        Title text message to be displayed
    text : str
        Text message to be displayed
    nrow : int
        The number of initial rows to be displayed, after which scrolling is used to the display the rest of the
        message.
    ncol: int
        The number of columns, that is width, to display the message.

    Returns
    -------
    None
    """

    layout1 = [[
        sg.Multiline(text,
                     size=(ncol, nrow),
                     background_color='white',
                     text_color='darkgreen',
                     font=font)
    ], [sg.CloseButton('OK')]]
    window1 = sg.Window('OPMRUN - OPM Flow Job Scheduler: ' + title,
                        layout=layout1)
    window1.Read()
    return ()
def elegir_oficina():
    '''
    DEVUELVE UN STRING CON EL "LookAndFeel"  QUE SE VA A USAR
    '''
    from registro_ambiental import cargar
    lookAndFeel = 'SystemDefault'
    dic = cargar()
    if len(list(dic.values())) > 0:
        layout = [[sg.T('Seleccione una de las oficinas de la lista.')],
                  [sg.InputCombo(list(dic.keys()), size=(20, 10), key='ofi')],
                  [sg.CloseButton('Seleccionar')]]
        window = sg.Window('Elegir Oficina').Layout(layout)
        event, buttons = window.Read()
        if event == 'Seleccionar':
            oficina = buttons['ofi']
            tempe = dic[oficina][-1]
            temperatura = tempe['Temperatura']
            if temperatura <= 10:
                lookAndFeel = 'TealMono'
            elif temperatura > 10 and temperatura <= 30:
                lookAndFeel = 'DarkBlue'
            else:
                lookAndFeel = 'Reddit'

    return lookAndFeel
예제 #11
0
def opm_popup(opmvers, text, nrow):
    """Display Text Message in a Display Window

    Displays a text message in a multiline popup. Normally used for displaying help information, but any text string
    can be used.

    Parameters
    ----------
    opmvers : str
        Version information to be displayed
    text : str
        Text message to be displayed
    nrow : int
        The number of initial rows to be displayed, after which scrolling is used to the display the rest of the
        message.

    Returns
    -------
    None
    """

    layout1 = [[sg.Multiline(text, size=(80, nrow), background_color='white', text_color='darkgreen')],
               [sg.CloseButton('OK')]]
    window1 = sg.Window('OPMRUN - Flow Job Scheduler ' + opmvers, layout=layout1)
    window1.Read()
    return ()
예제 #12
0
 def _init_annotator_gui(self, labels):
     layout = []
     row_layout = []
     i = 0
     for label in labels:
         i = i + 1
         if i % 5 == 0:
             layout.append(row_layout)
             row_layout = []
         label_button = sg.Button(button_text=label,
                                  key="LABEL_" + label,
                                  button_color=("white", "red"),
                                  font='Arial',
                                  size=(10, 2))
         row_layout.append(label_button)
         self._annotations[label_button.ButtonText] = {
             "START_TIME": [],
             "STOP_TIME": [],
             "Element": label_button
         }
     layout.append(row_layout)
     layout.append([sg.CloseButton('Close')])
     window = sg.Window("Annotator pad").layout(layout)
     while True:
         event, values = window.read()
         if event in (None,
                      'Close'):  # if user closes window or clicks cancel
             break
         if 'LABEL' in event:
             data = event.replace('LABEL_', '')
             self._update_button(data)
             self._update_annotations(data)
예제 #13
0
def main_window():
    layout = [[sg.Text('Guide Colour', pad=((10, 20), 5)),
               sg.Combo(['None', 'Yellow', 'Orange', 'Red', 'Grey'], default_value='None',
                        enable_events=True, key='-COMBO-', pad=((40, 10), 10), readonly=True)],
              [sg.Button('About', pad=((10, 50), 10), key='-ABOUT-'), sg.CloseButton('Close', pad=((30, 10), 10))]]

    return sg.Window('Screen guide', layout, icon=ico_image, size=(250, 100)).finalize()
예제 #14
0
def entryGUI(length, width):
    entryLayout = []

    # code from MikeyB from StackOverflow
    for i in range(width):
        line = [sg.InputText('', size=(3, 1)) for i in range(length)]
        entryLayout.append(line)

    entryLayout.append([sg.CloseButton("OK"), sg.CloseButton("Cancel")])

    entryWin = sg.Window("CodeWord Solver").Layout(entryLayout)
    button, values = entryWin.Read()

    if button != "OK":
        exit()
    else:
        return values
def mostrarReporte(fTit, fTex):
    '''
    MOSTRAR EN PANTALLA EL REPORTE DE LAS PALABRAS ERRONEAS
    '''
    # lista = verificarPalabra.mostrarReporte()
    layout_reporte = [[sg.Multiline(leerReporte(), font=fTex, disabled=True)],
                      [sg.CloseButton('Cerrar')]]
    window_reporte = sg.Window('Reporte de Palabras Erroneas',
                               font=fTit).Layout(layout_reporte)
    window_reporte.Read()
예제 #16
0
def pedirDefinicion(palabra):
    '''Se pide al usuario una definicion de la palabra que haya ingresado, en el caso en que no se pueda identificar.'''
    layout_definicion =[
            [sg.T('La palabra ingresada no se ha podido identificar. Por favor ingrese una definicion de la palabra')],
            [sg.Input('',key='def')],
            [sg.CloseButton('Ok')]
                        ]
    window_def = sg.Window('Palabra No Identificada').Layout(layout_definicion)
    event, definicion = window_def.Read()
    return definicion['def']
예제 #17
0
def show_message_box():
    sg.theme('Dark')  # please make your windows colorful

    alert_layout = [[sg.Text('Whole Foods purchase completed successfully!')],
                    [sg.CloseButton("Close")]]

    alert_window = sg.Window('Whole Foods Purchase Successful', alert_layout)

    alert_window.read()
    alert_window.close()
def backup_folder(f_use_str):
    prompt_str = f'\nIdentify the {f_use_str} file backup folder location...\n\n'
    sg.Popup('',
             prompt_str,
             background_color='#183a3e',
             text_color='#ffffff',
             keep_on_top=True)
    if len(sys.argv) == 1:
        event, (file_path, ) = sg.Window('My Script').Layout(
            [[sg.Text('Backup files destination')],
             [sg.In(size=(100, 10)), sg.FileBrowse()],
             [sg.CloseButton('Open'),
              sg.CloseButton('Cancel')]]).Read()
    else:
        file_path = sys.argv[1]
    if not file_path:
        sg.Popup("Cancel", "No folder was supplied.")
        raise SystemExit("Cancelling - no file folder path was supplied.")
    return file_path
예제 #19
0
def opm_popup(text, nrow):
    layout1 = [[
        sg.Multiline(text,
                     size=(80, nrow),
                     background_color='white',
                     text_color='darkgreen')
    ], [sg.CloseButton('OK')]]
    window1 = sg.Window('OPMRUN - Flow Job Scheduler ' +
                        opmvers).Layout(layout1)
    (button, values) = window1.Read()
    return ()
예제 #20
0
def about_window():
    layouth = [[sg.Image(app_image, size=(50, 50)),
               sg.Text('Name: Screen Guide (For Linux/Mac)' '\n' '\n'
                       'Version: 0.2' '\n' '\n'
                       'Copyright: 2020' '\n' '\n'
                       'Author: BabsKy' '\n' '\n'
                       'Description: A guide to help you focus on a particular area of your screen.' '\n'
                       'It can also be used as a colour filter.', size=(50, 12))],
               [sg.CloseButton('Close')]]

    return sg.Window('About Screen Guide', layouth, icon=ico_image, modal=True).read()
예제 #21
0
def gui_front():
    wm = "Welcome, to a basic LOC counter!\nWritten by Dillon Cain.\nMake sure you are in the correct directory.\nResults will follow with code and blank line counts.\n"
    sg.Popup(wm, auto_close=True, auto_close_duration=5)

    if len(sys.argv) == 1:
        event, (fname, ) = sg.Window('LOC Counter by Dillon Cain').Layout(
            [[sg.Text('Please select a file to count')],
             [sg.In(), sg.FileBrowse()],
             [sg.CloseButton('Open'),
              sg.CloseButton('Cancel')]]).Read()
    else:
        fname = sys.argv[1]

    if not fname:
        sg.Popup("Cancel", "No filename supplied")
        raise SystemExit("Cancelling: no filename supplied")
    print(event, fname)

    # Built in progress bar for fun plus people like status bars.

    for i in range(60):
        sg.OneLineProgressMeter('Counting in progress.....', i + 1, 60, 'key')

    # Start of loc counter
    handle = open(fname)  # Loads file into memory

    code_count = 0  # Init. variables
    line_spaces = 0
    c_line = 0
    for line in handle:
        line = line.rstrip()  # Removes whitespace on right side of line
        if not line.strip(
        ):  # Checks if line is empty and if so then it is a blank line
            line_spaces = line_spaces + 1
        elif line.startswith('#'):
            c_line = c_line + 1
        else:  # Last part of if else statement, where else results in there being a coded line
            code_count = code_count + 1

    sg.Popup('Lines that contain code:', code_count, 'Lines that are blank:',
             line_spaces)
예제 #22
0
 def Iniciar(self):
     # Layout
     layout = [
         [sg.Text('Faça sua pergunta: ')],
         [sg.Input()],
         [sg.Output(size=(20, 10))],
         [sg.Button('Decida')], [sg.CloseButton('Sair')]
     ]
     # Criar Janela
     self.janela = sg.Window('Decida!',layout=layout)
     while True:
         # Ler o valores
         self.eventos, self.valores = self.janela.Read()
         if self.eventos == 'Decida':
             print(random.choice(self.respostas))
예제 #23
0
def file_preview(csv_file):
    # modal window for csv file preview
    modal_layout = [[sg.Text(size=(70, 10), key='-preview-')],
                    [sg.CloseButton('Close')]]

    modal_window = sg.Window("Preview",
                             modal_layout,
                             modal=True,
                             finalize=True)
    while True:
        with open(csv_file, 'r') as csv_file_preview:
            # hardcoded: only first 10 rows
            csv_file_preview_head = [
                next(csv_file_preview) for line in range(10)
            ]
            modal_window['-preview-'].update(csv_file_preview_head)
        modal_event, modal_values = modal_window.read()
        if modal_event == "Exit" or modal_event == sg.WIN_CLOSED:
            break
    modal_window.close()
예제 #24
0
def create_goal_layout(program, edit):
    # To put to respective elements
    if edit:
        goal_val = program.goal
        startdate_val = program.start_date.isoformat()
        why_I_q = program.why_I_quit
    else:
        goal_val = 30
        startdate_val = date.today().isoformat()
        why_I_q = ""

    layout = [[
        sg.Text("Duration of challange: "),
        sg.Spin([n for n in range(1, 1000)], goal_val, key="-duration-")
    ],
              [
                  sg.Text("I'm starting on (day zero):"),
                  sg.InputText(startdate_val, key="-date-")
              ], [sg.Text("This is why I want to quit:")],
              [sg.Multiline(why_I_q, key="-whyIquit-")],
              [sg.Button("OK"), sg.CloseButton("Close")]]

    return layout
def log_window():
    log_file = get_log_file()
    with open(log_file, "r", encoding=FILE_ENCODING) as f:
        lines = f.readlines()

    _sg.theme('SystemDefault1')
    info = "{}, Version {}, (c) {}".format(APPNAME, __version__, __author__)
    layout = [[_sg.Text(log_file)],
              [_sg.Multiline("".join(lines), size=(80, 50))],
              [
                  _sg.Button("Delete Log", key="delete", size=(10, 2)),
                  _sg.CloseButton("Close", size=(20, 2))
              ]]
    window = _sg.Window(info, layout)

    while True:
        e, v = window.read()
        if e == "delete":
            # Open the file with writing permission
            myfile = open(log_file, 'w')
            myfile.close()
        break

    window.close()
예제 #26
0
def defineGUI():
    '''
    function to define and create the graphical interface, written with PySimpleGUI
    '''
    # check if GUI config file exist
    if args.instrument != None:
        instrument_default_value = args.instrument
    else:
        instrument_default_value = 'CTD'

    # get all devices
    devices = list(ti.keys())

    # change look and feel color scheme
    sg.ChangeLookAndFeel('SandyBeach')
    frameLayout = {}

    # define a frame layout for each instrument (device) with composite key as PRES_CTD, TEMP_XBT
    for d in devices:
        keys = cfg['split'][d.lower()].keys()
        # List comprehensions
        frameLayout[d] = [[
            sg.Checkbox(
                k,
                key='{:s}_{:s}'.format(k, d),
                tooltip='Select the extract the physical parameter {}'.format(
                    k))
        ] for k in keys]

    # define GUI layout
    layout = ([
        [sg.Text('File(s) to read and convert')],  # row 0
        [
            sg.Multiline(size=(40, 5), key='_IN_'),  # row 1, col 0
            sg.Input(
                key='_HIDDEN_',
                visible=False,  # row 1, col 1
                enable_events=True),
            sg.FilesBrowse(
                key='_HIDDEN_',
                initial_folder=None,  # row 1, col 2
                tooltip='Choose one or more files')
        ],
        [
            sg.Combo(
                list(ti.keys()),
                enable_events=True,
                size=(8, 1),  # row 2
                default_value=instrument_default_value,
                key='_DEVICE_',
                tooltip='Select the instrument')
        ],
        [
            sg.Frame(d,
                     frameLayout[d],
                     key='_FRAME_{:s}'.format(d),
                     visible=True)  # row 3
            for d in devices
        ],
        [sg.OK(), sg.CloseButton('Cancel')]
    ])  # row 4
    # [sg.CloseButton('Run'), sg.CloseButton('Cancel')]])

    # create a local instance windows used to reload the saved config from file
    window = sg.Window('Oceano converter', layout)
    window.Finalize()
    window.LoadFromDisk(configfile)

    return window
예제 #27
0
def start():
    event, values = sg.Window('Choice').Layout([
        [sg.Text('What would you like to do?')],
        [sg.Radio('Reorganize Raw Files', 'RADIO1', default=True)],  #0
        [sg.Radio('Combine New Files', 'RADIO1')],  #1
        [sg.Radio('Perform Basic Stats', 'RADIO1')],  #2
        [sg.CloseButton('Submit')]
    ]).Read()
    window = sg.Window('Bike Data Tool')
    window.Close()
    ## Define input and output folders
    if values[0] == True:
        event, values = sg.Window('Bike Data Tool').Layout([
            [sg.Text('Input folder')],
            [sg.In(), sg.FolderBrowse()],  #0
            [sg.Text('Output folder')],
            [sg.In(), sg.FolderBrowse()],  #1
            [sg.Text('Would you like to clean your data?')],
            [
                sg.Radio('Yes', "RADIO1", default=True),  #2
                sg.Radio('No', "RADIO1")
            ],  #3
            [sg.CloseButton('Submit'),
             sg.CloseButton('Cancel')]
        ]).Read()
        window = sg.Window('Bike Data Tool')
        window.Close()
        if event == 'Submit':
            raw_folder = values[0]
            # raw_folder = 'C:\\Users\\albei\\OneDrive\\Desktop\\analyze\\input'
            output_folder = values[1]
            # output_folder = 'C:\\Users\\albei\\OneDrive\\Desktop\\analyze\\output'
            manip = values[2]
            user_input(raw_folder, output_folder, manip)
        else:
            quit
    elif values[2] == True:
        event, values = sg.Window('Bike Data Analysis Tool').Layout([
            [sg.Text('Input folder')],
            [sg.In(), sg.FolderBrowse()],  #0
            [sg.Text('The files end in: ')],
            [
                sg.Radio('_new.xlsx', 'RADIO1', default=True),  #1
                sg.Radio('_new_raw.xlsx', 'RADIO1')
            ],
            [
                sg.Radio('Yes', 'RADIO2', default=True),  #2
                sg.Radio('No', 'RADDIO2')
            ],  #3
            [sg.CloseButton('Submit'),
             sg.CloseButton('Cancel')]
        ]).Read()
        window = sg.Window('Bike Data Analysis Tool')
        window.Close()
        if event == 'Submit':
            output_folder = values[0]
            # raw_folder = 'C:\\Users\\albei\\OneDrive\\Desktop\\analyze\\input'

            # Progress bar window #
            manip = values[1]
            ent_yes = values[2]
            df_avg(output_folder, manip, ent_yes)
        else:
            quit
    elif values[1] == True:
        ## Define input and output folders
        event, values = sg.Window('Bike Data Combining Tool').Layout([
            [sg.Text('Which folder are the files in?')],
            [sg.In(), sg.FolderBrowse()],  #0
            [sg.Text('Has the data been cleaned?')],
            [
                sg.Radio('Yes', "RADIO1", default=True),  #1
                sg.Radio('No', "RADIO1")
            ],  #2
            [sg.CloseButton('Submit'),
             sg.CloseButton('Cancel')]
        ]).Read()
        window = sg.Window('Bike Data Combining Tool')
        window.Close()

        output_folder = values[0]
        manip = values[1]
        if event == 'Submit':
            combine_excels(manip, output_folder)
        if event == 'Cancel':
            raise SystemError(0)
예제 #28
0
def buttonRow(names, close):
    if close:
        return list(map(lambda n: sg.CloseButton(n), names))
    return list(map(lambda n: sg.Button(n), names))
예제 #29
0
# -*- encoding: utf-8 -*-
import PySimpleGUI as sg
import sys

if len(sys.argv) == 1:
    event, (fname, ) = sg.Window('My Script').Layout(
        [[sg.Text('Document to open')], [sg.In(), sg.FileBrowse()],
         [sg.CloseButton('Open'),
          sg.CloseButton('Cancel')]]).Read()
else:
    fname = sys.argv[1]

if not fname:
    sg.Popup("Cancel", "No filename supplied")
    raise SystemExit("Cancelling: no filename supplied")
print(event, fname)
예제 #30
0
def main():
    targetDialogue = [
        [sg.Text("Select the type of image to measure:", size=(35, 1))],
        [sg.Radio("Standard", "Target", default=True)],
        [sg.Radio("With Particles", "Target", default=False)],
        [sg.Radio("Poor Lighting + Particles", "Target", default=False)],
        [sg.Radio("Testing with New Inputs", "Target", default=False)],
        [sg.CloseButton("Select")]
    ]

    targetWindow = sg.Window('Graynne').Layout(targetDialogue)
    button, values = targetWindow.Read()

    target = values.index(True) + 1  # to be used to determine pickle file

    if target == 4:
        targetDataDialogue = [
            [sg.Text("Select the target database to utilize:", size=(35, 1))],
            [sg.Radio("Standard", "Target", default=True)],
            [sg.Radio("With Particles", "Target", default=False)],
            [sg.Radio("Poor Lighting + Particles", "Target", default=False)],
            [sg.CloseButton("Select")]
        ]

        targetDataWindow = sg.Window('Graynne').Layout(targetDataDialogue)
        button, values = targetDataWindow.Read()

        targetData = values.index(
            True) + 1  # to be used to determine pickle file
    else:
        targetData = target

    fileName = "Select File"
    while fileName == "Select File":
        fileDialogue = [[sg.Text("Choose an Input File", size=(35, 1))],
                        [
                            sg.Text("Input File",
                                    size=(15, 1),
                                    auto_size_text=False,
                                    justification="right"),
                            sg.InputText("Select File"),
                            sg.FileBrowse()
                        ],
                        [sg.CloseButton("Select"),
                         sg.CloseButton("Cancel")]]

        fileWindow = sg.Window('Graynne').Layout(fileDialogue)
        button, values = fileWindow.Read()

        fileName = values[0]
        if fileName == "Select File" and button == "Select":
            wrongDialogue = [[sg.Text("You must specify a file path.")],
                             [sg.CloseButton("OK")]]

            wrongWindow = sg.Window('Graynne').Layout(wrongDialogue)
            button = wrongWindow.Read()
        elif button == "Cancel":
            exit()

    if fileName[-6] == "_":
        num = int(fileName[-5])
        outPath = fileName[:-40]
    elif fileName[-7] == "_":
        num = int(fileName[-6:-4])
        outPath = fileName[:-41]
    elif fileName[-8] == "_":
        num = int(fileName[-7:-4])
        outPath = fileName[:-42]
    else:
        raise Exception("Image number not in expected format.")

    shortFile = "image_" + str(num)

    logmodel = genLogModel(targetData)
    predictions = genPredictions(fileName, logmodel)

    fractionDark = writeGraynne(predictions)

    outString = "The fraction of dark phase in {} is {:.5}, and the output has been written to: \n".format(
        shortFile, fractionDark)
    outFile = outPath + "DeltaHacks V/src/output.png"
    outDialogue = [[sg.Text(outString + outFile)], [sg.CloseButton("OK")]]

    outWindow = sg.Window('Graynne').Layout(outDialogue)
    button = outWindow.Read()