예제 #1
0
def gui():

    #  Gui to get dates from the user
    dates = []
    layout = [[sg.Text('GBO Master Calibration Finder', font=('Helvetica', 25), justification='center')],
              [sg.Text('_' * 100, size=(65, 1))],
              [sg.Text('Enter the dates of science images', font=('Helvetica', 14))],
              [sg.T('Format: 20180715'), sg.T('Added Date', size=(19,1), justification='right')],
              [sg.InputText('', size=(12, 1), key='datein'),
              sg.T('', size=(20, 1), justification='right', key='dateout')],
              [sg.Submit('Add Date')],
              [sg.Button('Next'), sg.Button('Exit')]]

    window = sg.Window('Window Title').Layout(layout)

    while True:  # Event Loop
        event, values = window.Read()
        print event, values
        if event is None or event == 'Exit':
            print '\nClosing program based on "Exit" command'
            sys.exit(1)
            break
        if event == 'Next':
            break
        if event == 'Add Date':
            dates.append(values['datein'])
            window.Element('dateout').Update(values['datein'])

    window.Close()


    #  Gui to get Path, Binning, and Temp from user
    layout = [[sg.Text('GBO Master Calibration Finder', font=('Helvetica', 25), justification='center')],
              [sg.Text('_' * 100, size=(65, 1))],
              [sg.Text('Enter output path for your files', font=('Helvetica', 12))],
              [sg.InputText(outdir, size=(45, 1), key='path'), sg.Text('Leave as is for default')],
              [sg.Text('_' * 100, size=(65, 1))],
              [sg.Text('Select the type of master frames to find', font=('Helvetica', 14))],
              [sg.Checkbox('Bias', default=True, size=(12, 1), key='Bias'),
               sg.Checkbox('Dark', default=True, size=(12, 1), key='Dark'),
               sg.Checkbox('Flat', default=True, size=(12, 1), key='Flat')],
              [sg.Text('_' * 100, size=(65, 1))],
              [sg.Text('Select the Binning', font=('Helvetica', 14))],
              [sg.Radio('1X1', "RADIO1", default=True, key='1X1'), sg.Radio('2X2', "RADIO1", key='2X2'),
               sg.Radio('3X3', "RADIO1", key='3X3'), sg.Radio('4X4', "RADIO1", key='4X4')],
              [sg.Text('_' * 100, size=(65, 1))],
              [sg.Text('Select the Temp', font=('Helvetica', 14))],
              [sg.Radio('-25', "RADIO2", default=True, key='-25'), sg.Radio('-30', "RADIO2", key='-30'),
               sg.Radio('-35', "RADIO2", key='-35')],
              [sg.Submit(), sg.Button('Exit')]]

    window = sg.Window('GBO Master Calibration Finder', font=("Helvetica", 12)).Layout(layout)

    event, values = window.Read()
    if event == 'Exit':
        print '\nClosing program based on "Exit" command'
        sys.exit(2)

    window.Close()

    types = ['Bias', 'Dark', 'Flat']
    types = [x for x in types if values[x] == True]
    binning = [x for x in bins if values[x] == True]
    binning = binning[0]
    temp = [x for x in temps if values[x] == True]
    temp = temp[0]

    outpath = values['path']
    if not outpath.endswith('\\'):
        outpath = outpath + '\\'


    #  Gui to get dark exposure times from the user
    if 'Dark' in types:
        darkbin = dark_files.where(done_files['binning'] == binning)
        darkbin.dropna(how='all', inplace=True)
        darktemp = darkbin.where(darkbin['temp'] == temp)
        darktemp.dropna(how='all', inplace=True)

        exposures = np.sort(darktemp['exp'].unique())

        layout = [[sg.Text('GBO Master Calibration Finder', font=('Helvetica', 25), justification='center')],
                  [sg.Text('Your Binning is:'), sg.Text(binning)],
                  [sg.Text('Your Temp is:', size=(12,1)), sg.Text(temp)],
                  [sg.Text('',size=(15,1)), sg.Text('Available Exposures')],
                  [sg.Text('', size=(16,1)),
                   sg.Listbox(exposures, size=(10,12), select_mode='multiple', key='exposures')],
                  [sg.Submit(), sg.Button('Exit')]]

        window = sg.Window('GBO Master Calibration Finder', font=("Helvetica", 12)).Layout(layout)

        event, values = window.Read()

        window.Close()

        if event == 'Exit':
            print '\nClosing program based on "Exit" command'
            sys.exit(3)

        exposures = values['exposures']
    else:
        exposures = []

    #  Gui to get filters from the user
    if 'Flat' in types:
        flatbin = flat_files.where(done_files['binning'] == binning)
        flatbin.dropna(how='all', inplace=True)
        flattemp = flatbin.where(flatbin['temp'] == temp)
        flattemp.dropna(how='all', inplace=True)

        filters = np.sort(flattemp['filter'].unique())

        layout = [[sg.Text('GBO Master Calibration Finder', font=('Helvetica', 25), justification='center')],
                  [sg.Text('Your Binning is:'), sg.Text(binning)],
                  [sg.Text('Your Temp is:', size=(12,1)), sg.Text(temp)],
                  [sg.Text('',size=(15,1)), sg.Text('Available Filters')],
                  [sg.Text('', size=(16,1)),
                   sg.Listbox(filters, size=(10,12), select_mode='multiple', key='filters')],
                  [sg.Submit(), sg.Button('Exit')]]

        window = sg.Window('GBO Master Calibration Finder', font=("Helvetica", 12)).Layout(layout)

        event, values = window.Read()

        window.Close()

        if event == 'Exit':
            print '\nClosing program based on "Exit" command'
            sys.exit(4)

        filters = values['filters']
    else:
        filters = []

    return types, outpath, binning, temp, dates, exposures, filters
예제 #2
0
 [
     sg.Text('All graphic widgets in one form!',
             size=(30, 1),
             justification='center',
             font=("Helvetica", 25),
             relief=sg.RELIEF_RIDGE)
 ], [sg.Text('Here is some text.... and a place to enter text')],
 [sg.InputText('This is my text')],
 [
     sg.Frame(layout=[[
         sg.Checkbox('Checkbox', size=(10, 1)),
         sg.Checkbox('My second checkbox!', default=True)
     ],
                      [
                          sg.Radio('My first Radio!     ',
                                   "RADIO1",
                                   default=True,
                                   size=(10, 1)),
                          sg.Radio('My second Radio!', "RADIO1")
                      ]],
              title='Options',
              title_color='red',
              relief=sg.RELIEF_SUNKEN,
              tooltip='Use these to set flags')
 ],
 [
     sg.Multiline(
         default_text=
         'This is the default Text should you decide not to type anything',
         size=(35, 3)),
     sg.Multiline(default_text='A second multi-line', size=(35, 3))
 ],
예제 #3
0
def Everything():
    sg.ChangeLookAndFeel('TanBlue')

    column1 = [[
        sg.Text('Column 1',
                background_color=sg.DEFAULT_BACKGROUND_COLOR,
                justification='center',
                size=(10, 1))
    ],
               [
                   sg.Spin(values=('Spin Box 1', '2', '3'),
                           initial_value='Spin Box 1',
                           key='spin1')
               ],
               [
                   sg.Spin(values=('Spin Box 1', '2', '3'),
                           initial_value='Spin Box 2',
                           key='spin2')
               ],
               [
                   sg.Spin(values=('Spin Box 1', '2', '3'),
                           initial_value='Spin Box 3',
                           key='spin3')
               ]]

    layout = [
        [
            sg.Text('All graphic widgets in one form!',
                    size=(30, 1),
                    font=("Helvetica", 25))
        ], [sg.Text('Here is some text.... and a place to enter text')],
        [sg.InputText('This is my text', key='in1', do_not_clear=True)],
        [
            sg.Checkbox('Checkbox', key='cb1'),
            sg.Checkbox('My second checkbox!', key='cb2', default=True)
        ],
        [
            sg.Radio('My first Radio!     ',
                     "RADIO1",
                     key='rad1',
                     default=True),
            sg.Radio('My second Radio!', "RADIO1", key='rad2')
        ],
        [
            sg.Multiline(
                default_text=
                'This is the default Text should you decide not to type anything',
                size=(35, 3),
                key='multi1',
                do_not_clear=True),
            sg.Multiline(default_text='A second multi-line',
                         size=(35, 3),
                         key='multi2',
                         do_not_clear=True)
        ],
        [
            sg.InputCombo(('Combobox 1', 'Combobox 2'),
                          key='combo',
                          size=(20, 1)),
            sg.Slider(range=(1, 100),
                      orientation='h',
                      size=(34, 20),
                      key='slide1',
                      default_value=85)
        ],
        [
            sg.InputOptionMenu(
                ('Menu Option 1', 'Menu Option 2', 'Menu Option 3'),
                key='optionmenu')
        ],
        [
            sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'),
                       size=(30, 3),
                       key='listbox'),
            sg.Slider(
                range=(1, 100),
                orientation='v',
                size=(5, 20),
                default_value=25,
                key='slide2',
            ),
            sg.Slider(
                range=(1, 100),
                orientation='v',
                size=(5, 20),
                default_value=75,
                key='slide3',
            ),
            sg.Slider(range=(1, 100),
                      orientation='v',
                      size=(5, 20),
                      default_value=10,
                      key='slide4'),
            sg.Column(column1, background_color='gray34')
        ], [sg.Text('_' * 80)], [sg.Text('Choose A Folder', size=(35, 1))],
        [
            sg.Text('Your Folder',
                    size=(15, 1),
                    auto_size_text=False,
                    justification='right'),
            sg.InputText('Default Folder', key='folder', do_not_clear=True),
            sg.FolderBrowse()
        ],
        [
            sg.ReadButton('Exit'),
            sg.Text(' ' * 40),
            sg.ReadButton('SaveSettings'),
            sg.ReadButton('LoadSettings')
        ]
    ]

    window = sg.Window('Form Fill Demonstration',
                       default_element_size=(40, 1),
                       grab_anywhere=False)
    # button, values = window.LayoutAndRead(layout, non_blocking=True)
    window.Layout(layout)

    while True:
        button, values = window.Read()

        if button is 'SaveSettings':
            filename = sg.PopupGetFile('Save Settings',
                                       save_as=True,
                                       no_window=True)
            window.SaveToDisk(filename)
            # save(values)
        elif button is 'LoadSettings':
            filename = sg.PopupGetFile('Load Settings', no_window=True)
            window.LoadFromDisk(filename)
            # load(form)
        elif button in ['Exit', None]:
            break
예제 #4
0
layout = [[
    sg.T('Notes:', pad=((3, 0), 0)),
    sg.In(size=(44, 1),
          background_color='white',
          text_color='black',
          key='notes')
],
          [
              sg.T('Output:', pad=((3, 0), 0)),
              sg.T('', size=(44, 1), text_color='white', key='output')
          ],
          [
              sg.CBox('Checkbox:', default=True, pad=((3, 0), 0), key='cbox'),
              sg.Listbox((1, 2, 3, 4), size=(8, 3), key='listbox'),
              sg.Radio('Radio 1', default=True, group_id='1', key='radio1'),
              sg.Radio('Radio 2', default=False, group_id='1', key='radio2')
          ],
          [
              sg.Spin((1, 2, 3, 4), 1, key='spin'),
              sg.OptionMenu((1, 2, 3, 4), key='option'),
              sg.Combo(values=(1, 2, 3, 4), key='combo')
          ], [sg.Multiline('Multiline', size=(20, 3), key='multi')],
          [sg.Slider((1, 10), size=(20, 20), orientation='h', key='slider')],
          [
              sg.ReadButton('Enable', button_color=('white', 'black')),
              sg.ReadButton('Disable', button_color=('white', 'black')),
              sg.ReadButton('Reset',
                            button_color=('white', '#9B0023'),
                            key='reset'),
              sg.ReadButton('Values', button_color=('white', 'springgreen4')),
예제 #5
0
def MachineLearningGUI():
    sg.SetOptions(text_justification='right')

    flags = [
        [
            sg.Checkbox('Normalize', size=(12, 1), default=True),
            sg.Checkbox('Verbose', size=(20, 1))
        ],
        [
            sg.Checkbox('Cluster', size=(12, 1)),
            sg.Checkbox('Flush Output', size=(20, 1), default=True)
        ],
        [
            sg.Checkbox('Write Results', size=(12, 1)),
            sg.Checkbox('Keep Intermediate Data', size=(20, 1))
        ],
        [
            sg.Checkbox('Normalize', size=(12, 1), default=True),
            sg.Checkbox('Verbose', size=(20, 1))
        ],
        [
            sg.Checkbox('Cluster', size=(12, 1)),
            sg.Checkbox('Flush Output', size=(20, 1), default=True)
        ],
        [
            sg.Checkbox('Write Results', size=(12, 1)),
            sg.Checkbox('Keep Intermediate Data', size=(20, 1))
        ],
    ]

    loss_functions = [
        [
            sg.Radio('Cross-Entropy', 'loss', size=(12, 1)),
            sg.Radio('Logistic', 'loss', default=True, size=(12, 1))
        ],
        [
            sg.Radio('Hinge', 'loss', size=(12, 1)),
            sg.Radio('Huber', 'loss', size=(12, 1))
        ],
        [
            sg.Radio('Kullerback', 'loss', size=(12, 1)),
            sg.Radio('MAE(L1)', 'loss', size=(12, 1))
        ],
        [
            sg.Radio('MSE(L2)', 'loss', size=(12, 1)),
            sg.Radio('MB(L0)', 'loss', size=(12, 1))
        ],
    ]

    command_line_parms = [
        [
            sg.Text('Passes', size=(8, 1)),
            sg.Spin(values=[i for i in range(1, 1000)],
                    initial_value=20,
                    size=(6, 1)),
            sg.Text('Steps', size=(8, 1), pad=((7, 3))),
            sg.Spin(values=[i for i in range(1, 1000)],
                    initial_value=20,
                    size=(6, 1))
        ],
        [
            sg.Text('ooa', size=(8, 1)),
            sg.In(default_text='6', size=(8, 1)),
            sg.Text('nn', size=(8, 1)),
            sg.In(default_text='10', size=(10, 1))
        ],
        [
            sg.Text('q', size=(8, 1)),
            sg.In(default_text='ff', size=(8, 1)),
            sg.Text('ngram', size=(8, 1)),
            sg.In(default_text='5', size=(10, 1))
        ],
        [
            sg.Text('l', size=(8, 1)),
            sg.In(default_text='0.4', size=(8, 1)),
            sg.Text('Layers', size=(8, 1)),
            sg.Drop(values=('BatchNorm', 'other'), auto_size_text=True)
        ],
    ]

    layout = [[
        sg.Frame('Command Line Parameteres',
                 command_line_parms,
                 title_color='green',
                 font='Any 12')
    ], [sg.Frame('Flags', flags, font='Any 12', title_color='blue')],
              [
                  sg.Frame('Loss Functions',
                           loss_functions,
                           font='Any 12',
                           title_color='red')
              ], [sg.Submit(), sg.Cancel()]]

    window = sg.Window('Machine Learning Front End',
                       font=("Helvetica", 12)).Layout(layout)
    button, values = window.Read()
    sg.SetOptions(text_justification='left')

    print(button, values)