Example #1
0
def Launcher2():
    sg.ChangeLookAndFeel('GreenTan')
    window = sg.Window('Script launcher')

    filelist = glob.glob(LOCATION_OF_YOUR_SCRIPTS + '*.py')
    namesonly = []
    for file in filelist:
        namesonly.append(ntpath.basename(file))

    layout = [
        [
            sg.Listbox(values=namesonly,
                       size=(30, 19),
                       select_mode=sg.SELECT_MODE_EXTENDED,
                       key='demolist'),
            sg.Output(size=(88, 20), font='Courier 10')
        ],
        [
            sg.Checkbox('Wait for program to complete',
                        default=False,
                        key='wait')
        ],
        [
            sg.ReadButton('Run'),
            sg.ReadButton('Shortcut 1'),
            sg.ReadButton('Fav Program'),
            sg.Button('EXIT')
        ],
    ]

    window.Layout(layout)

    # ---===--- Loop taking in user input and using it to query HowDoI --- #
    while True:
        (button, value) = window.Read()
        if button in ('EXIT', None):
            break  # exit button clicked
        if button in ('Shortcut 1', 'Fav Program'):
            print(
                'Quickly launch your favorite programs using these shortcuts')
            print(
                'Or  copy files to your github folder.  Or anything else you type on the command line'
            )
            # copyfile(source, dest)
        elif button is 'Run':
            for index, file in enumerate(value['demolist']):
                print('Launching %s' % file)
                window.Refresh()  # make the print appear immediately
                if value['wait']:
                    execute_command_blocking(LOCATION_OF_YOUR_SCRIPTS + file)
                else:
                    execute_command_nonblocking(LOCATION_OF_YOUR_SCRIPTS +
                                                file)
Example #2
0
def HowDoI():
    '''
    Make and show a window (PySimpleGUI form) that takes user input and sends to the HowDoI web oracle
    Excellent example of 2 GUI concepts
        1. Output Element that will show text in a scrolled window
        2. Non-Window-Closing Buttons - These buttons will cause the form to return with the form's values, but doesn't close the form
    :return: never returns
    '''
    # -------  Make a new Window  ------- #
    sg.ChangeLookAndFeel('GreenTan')            # give our form a spiffy set of colors

    layout =  [
                [sg.Text('Ask and your answer will appear here....', size=(40, 1))],
                [sg.Output(size=(127, 30), font=('Helvetica 10'))],
                [ sg.Spin(values=(1, 2, 3, 4), initial_value=1, size=(2, 1), key='Num Answers', font='Helvetica 15'),
                  sg.Text('Num Answers',font='Helvetica 15'), sg.Checkbox('Display Full Text', key='full text', font='Helvetica 15'),
                sg.T('Command History', font='Helvetica 15'), sg.T('', size=(40,3), text_color=sg.BLUES[0], key='history')],
                [sg.Multiline(size=(85, 5), enter_submits=True, key='query', do_not_clear=False),
                sg.ReadButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0]), bind_return_key=True),
                sg.Button('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]
              ]

    window = sg.Window('How Do I ??', default_element_size=(30, 2), icon=DEFAULT_ICON, font=('Helvetica',' 13'), default_button_element_size=(8,2), return_keyboard_events=True, no_titlebar=True, grab_anywhere=True)
    window.Layout(layout)
    # ---===--- Loop taking in user input and using it to query HowDoI --- #
    command_history = []
    history_offset = 0
    while True:
        (button, value) = window.Read()
        if button is 'SEND':
            query = value['query'].rstrip()
            print(query)
            QueryHowDoI(query, value['Num Answers'], value['full text'])  # send the string to HowDoI
            command_history.append(query)
            history_offset = len(command_history)-1
            window.FindElement('query').Update('')                       # manually clear input because keyboard events blocks clear
            window.FindElement('history').Update('\n'.join(command_history[-3:]))
        elif button is None or button is 'EXIT':            # if exit button or closed using X
            break
        elif 'Up' in button and len(command_history):                                # scroll back in history
            command = command_history[history_offset]
            history_offset -= 1 * (history_offset > 0)      # decrement is not zero
            window.FindElement('query').Update(command)
        elif 'Down' in button and len(command_history):                              # scroll forward in history
            history_offset += 1 * (history_offset < len(command_history)-1) # increment up to end of list
            command = command_history[history_offset]
            window.FindElement('query').Update(command)
        elif 'Escape' in button:                            # clear currently line
            window.FindElement('query').Update('')
Example #3
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
Example #4
0
    [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 3')]
]

layout = [
    [sg.Menu(menu_def, tearoff=True)],
    [
        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')
    ],
    [
Example #5
0
layout = [
    [
        sg.Text("Python Script:", size=(13, 1)),
        sg.InputText("", key="py-file", do_not_clear=True),
        sg.FileBrowse(button_text="...", file_types=(("Python Files", "*.py*"),)),
    ],
    [
        sg.Text("Output Folder:", size=(13, 1)),
        frm_output,
        sg.FolderBrowse(button_text="..."),
    ],
    [sg.Text("Icon File:", size=(13, 1)), frm_icon, sg.FileBrowse(button_text="...")],
    [
        sg.Text("App control:", size=(15, 1)),
        sg.Checkbox("Use Console", default=True, key="use-console"),
        sg.Checkbox("Tk Support", default=False, key="tk-support"),
        sg.Checkbox("Qt Support", default=False, key="qt-support"),
        sg.Checkbox("Numpy Support", default=False, key="np-support"),
    ],
    [
        sg.Text("Output control:", size=(15, 1)),
        sg.Checkbox("Remove <.build> folder", default=True, key="remove-build"),
        sg.Checkbox("Use UPX-Packer", default=False, key="compress"),
    ],
    [
        sg.Text("Dep. cache control:", size=(15, 1)),
        sg.Checkbox("Ignore", text_color="#FF0000", default=False, key="ignore-cache"),
        sg.Checkbox("Recurse", text_color="#FF0000", default=False, key="int-depend"),
        sg.Checkbox(
            "Rebuild", text_color="#FF0000", default=False, key="rebuild-cache"
Example #6
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
Example #7
0
layout = [[
    sg.Text("Python Script:", size=(13, 1)),
    sg.InputText("", key="py-file", do_not_clear=True),
    sg.FileBrowse(button_text="...", file_types=(("Python Files", "*.py*"), ))
],
          [
              sg.Text("Output Folder:", size=(13, 1)), frm_output,
              sg.FolderBrowse(button_text="...")
          ],
          [
              sg.Text("Icon File:", size=(13, 1)), frm_icon,
              sg.FileBrowse(button_text="...")
          ],
          [
              sg.Checkbox("Remove <.build>", default=True, key="remove-build"),
              sg.Checkbox("Use UPX-Packer", default=False, key="compress"),
              sg.Checkbox("Rebuild Dep. Cache",
                          text_color="#FF0000",
                          default=False,
                          key="rebuild-cache"),
              sg.Checkbox("Skim Binaries (Caution!)",
                          text_color="#FF0000",
                          default=False,
                          key="skim"),
          ],
          [
              sg.Checkbox("Use Console", default=True, key="use-console"),
              sg.Checkbox("Tk Support", default=False, key="tk-support"),
              sg.Checkbox("Qt Support", default=False, key="qt-support")
          ], [sg.Text("Recurse into:", size=(13, 1)), frm_follow],
Example #8
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)