예제 #1
0
 def __init__(self, title=__title__):
     super(TestingWindow, self).__init__(title)
     self.title = title
     self.paused = True
     self.image2D = True
     self.exit = False
     self.layout = [[
         sg.Text(title,
                 size=(40, 1),
                 justification="center",
                 font=("wingdings", 20))
     ],
                    [
                        sg.Image(filename="", key="image_color"),
                        sg.Image(filename="", key="image_depth")
                    ],
                    [
                        sg.Image(filename="", key="image_color_cropped"),
                        sg.Image(filename="", key="image_depth_cropped")
                    ],
                    [
                        sg.Button(button_text="Start",
                                  key="Start",
                                  size=(7, 1),
                                  font=("wingdings", 14)),
                        sg.Button(button_text="Resume",
                                  key="Resume",
                                  size=(7, 1),
                                  font=("wingdings", 14),
                                  visible=False),
                        sg.Button(button_text="Pause",
                                  key="Pause",
                                  size=(7, 1),
                                  font=("Verdana", 14)),
                        sg.Button(button_text="Stop",
                                  key="Stop",
                                  size=(7, 1),
                                  font=("Verdana", 14))
                    ],
                    [
                        sg.Button(button_text="Save PNG",
                                  key="Save_PNG",
                                  size=(10, 1),
                                  font=("verdana", 14)),
                        sg.Button(button_text="Take Frames",
                                  key="Take_Frames",
                                  size=(10, 1),
                                  font=("verdana", 14)),
                        sg.Button(button_text="Save PLY",
                                  key="Save_PLY",
                                  size=(10, 1),
                                  font=("verdana", 14)),
                        sg.Button(button_text="Exit",
                                  key="Exit",
                                  size=(10, 1),
                                  font=("verdana", 14)),
                    ]]
     self.window = None
예제 #2
0
    def __init__(self, title=__title__):
        super(WImageLoaded, self).__init__(title)
        self.title = title
        self.paused = True
        self.image2D = True
        self.exit = False
        self.layout = [[
            sg.Frame(title="",
                     layout=[[
                         sg.Text("File RGB:", size=(10, 1)),
                         sg.Input(key="InputRGB"),
                         sg.FileBrowse()
                     ], [sg.Submit(key="SubmitRGB")],
                             [sg.Text("", key="RGB_error", visible=False)],
                             [sg.Image(filename="", key="RGB_img")]]),
            sg.Frame(title="",
                     layout=[[
                         sg.Text("File Depth:", size=(10, 1)),
                         sg.Input(key="InputDepth"),
                         sg.FileBrowse()
                     ], [sg.Submit(key="SubmitDepth")],
                             [sg.Text("", key="Depth_error", visible=False)],
                             [sg.Image(filename="", key="Depth_img")]])
        ],
                       [
                           sg.Button(button_text="Exit",
                                     key="Exit",
                                     size=(10, 1),
                                     font=("verdana", 14))
                       ]]

        self.window = None
예제 #3
0
    def __init__(self, title=__title__):
        super(WStarting, self).__init__(title)
        self.seconds = 24
        self.paused = False
        self.layout = [[
            sg.Frame(title="Additional options:",
                     layout=[[
                         sg.Button(button_text="Watch Live",
                                   key="watch_live",
                                   size=(10, 1),
                                   font=("wingdings", 14)),
                         sg.Button(button_text="Load File",
                                   key="load_file",
                                   size=(10, 1),
                                   font=("wingdings", 14)),
                     ]],
                     size=(25, 3),
                     relief=sg.RELIEF_SUNKEN)
        ],
                       [
                           sg.Button(button_text="Start Component",
                                     key="start_component",
                                     size=(16, 1),
                                     font=("wingdings", 14))
                       ],
                       [
                           sg.Text("The component will start automatically",
                                   auto_size_text=True,
                                   justification="left")
                       ],
                       [
                           sg.ProgressBar(max_value=self.seconds,
                                          key="countdown",
                                          orientation="h",
                                          size=(20, 20))
                       ],
                       [
                           sg.Button(button_text="Exit",
                                     key="Exit",
                                     size=(10, 1),
                                     font=("verdana", 14)),
                       ]]

        self.window = None
        self.progress_bar = None
예제 #4
0
def user_info(json_data):
    layout = [[
        sg.Text(time.asctime(time.localtime(time.time())),
                font=("Helvetica", 18),
                justification='center',
                size=(25, 1))
    ],
              [
                  sg.Text('Name: ', size=(10, 1), font=("Helvetica", 18)),
                  sg.Text(json_data['name'], font=("Helvetica", 18))
              ],
              [
                  sg.Text('Number: ', size=(10, 1), font=("Helvetica", 18)),
                  sg.Text(json_data['phone'], font=("Helvetica", 18))
              ],
              [
                  sg.Text('Is logged in? ',
                          size=(10, 1),
                          font=("Helvetica", 18)),
                  sg.Text(str(json_data['signedIN']), font=("Helvetica", 18))
              ], [sg.Button('Log In', key='logger'),
                  sg.Button('Cancel')]]

    window = sg.Window('User Information').Layout(layout)

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

        if json_data['signedIN']:
            element = window.FindElement('logger')
            element.Update(text='Log Out')

        if button == 'Cancel':
            return json_data
        elif button == 'Log In' or values is None:
            json_data['signedIN'] = True
            json_data['timeLogs'].append(
                time.asctime(time.localtime(time.time())))
            return json_data
        elif button == 'Log Out' or values is None:
            json_data['signedIN'] = False
            json_data['timeLogs'].append(
                time.asctime(time.localtime(time.time())))
            return json_data
def ChatBotWithHistory():
    # -------  Make a new Window  ------- #
    sg.ChangeLookAndFeel('GreenTan')  # give our form a spiffy set of colors

    layout = [[sg.Text('Your output will go here', size=(40, 1))],
              [sg.Output(size=(127, 30), font=('Helvetica 10'))],
              [sg.T('Command History'),
               sg.T('', size=(20, 3), 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('Chat window with history',
                       default_element_size=(30, 2),
                       font=('Helvetica', ' 13'),
                       default_button_element_size=(8, 2),
                       return_keyboard_events=True).Layout(layout)

    # ---===--- Loop taking in user input and using it  --- #
    command_history = []
    history_offset = 0
    while True:
        (button, value) = window.Read()
        if button is 'SEND':
            query = value['query'].rstrip()
            # EXECUTE YOUR COMMAND HERE
            print('The command you entered was {}'.format(query))
            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':  # quit if exit button or X
            break
        elif 'Up' in button and len(command_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):
            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:
            window.FindElement('query').Update('')

    sys.exit(69)
예제 #6
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)
예제 #7
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('')
예제 #8
0
def getEvent():

    # variables
    database = '/Users/DavidBailey/db/pythonsqlite.db'
    table = "events_pt"
    value = 'urban'

    # connect to sqlite
    conn = sqlite3.connect(database)
    BASE_DIR = os.path.dirname(os.path.abspath(__file__))
    db_path = os.path.join(BASE_DIR, database)
    with sqlite3.connect(db_path) as db:

        # gui layout
        sg.SetOptions(
            button_color=sg.COLOR_SYSTEM_DEFAULT
            , text_color=sg.COLOR_SYSTEM_DEFAULT
        )
        layout = [[sg.Text('Enter text here', size=(40, 1), font=800)],
                  [sg.Text('What type of event?', size=(15, 1), font=800),
                   # values in event column in database
                   sg.InputCombo(('urban', 'outdoors - hike', 'outdoors - no hike', 'outdoors - hard hike', '13er',
                                  '14er', 'backpacking'), size=(20, 1))],
                  [sg.Button('Submit')]]

        window = sg.Window('Digital Bucket').Layout(layout)
        button, values = window.Read()
        value = ''.join(values)

        # select query on database
        cursor = conn.cursor()
        cursor.execute("SELECT event FROM %s where complete = 'N' and type = '%s'" % (table, value))
        event_list = []
        for record in cursor:
            event_list.append(record)
        main_value_list = random.choice(event_list)
        main_value = ''.join(main_value_list)
        print value
        print main_value

        # update query on database
        cursor.execute("UPDATE %s SET complete = 'Y' where event = '%s' and type = '%s'" % (table, main_value, value))
        conn.commit()

        # show value in gui popup
        sg.Popup('You are going to....', main_value, font='800', size=(40, 1))
예제 #9
0
def parseWindow(
        window):  #parses all buttons,checkboxes, etc. for the selected window
    event, values = window.Read()
    event, values = window.Read()
    if event is None or event == "Exit":
        return 0
    elif event == "Open Config":
        fileName = openFileBox()
        os.system("gnome-terminal -e nano " + fileName)
        return 1
    elif event == "Add Account":
        addAccount()
        return 1
    elif event == "Add Client":
        addClient()
        return 1
    elif event == "Add Module":
        addModule()
        return 1
    elif event == "About":
        help = open(currentDir + "/../../README.md", "r").read()
        sg.PopupScrolled(help)
        return 1
    else:
        print event, values

    if event == "Execute":
        if values[1] == "Checkup":
            fullCheckup()
            return 1
        elif values[1] == "Single Account Checkup":
            layoutSingleAccountCheckup = [[
                sg.Listbox(values=(accounts.values()), size=(50, 20))
            ], [sg.Button("OK")]]
            windowSingleAccountCheckup = sg.Window("Check on which account?",
                                                   layoutSingleAccountCheckup)
            eventSC, valuesSC = windowSingleAccountCheckup.Read()
            #print valuesSC
            #print valuesSC[0][0][0]
            #print valuesSC[0][0][1]
            singleAccount(valuesSC[0][0][0], valuesSC[0][0][1])
        else:
            print(event, values)
    return 1
def Launcher():

    # def print(line):
    #     window.FindElement('output').Update(line)

    sg.ChangeLookAndFeel('Dark')

    namesonly = [f for f in os.listdir(ROOT_PATH) if f.endswith('.py')]

    sg.SetOptions(element_padding=(0, 0),
                  button_element_size=(12, 1),
                  auto_size_buttons=False)

    layout = [[
        sg.Combo(values=namesonly, size=(35, 30), key='demofile'),
        sg.ReadButton('Run', button_color=('white', '#00168B')),
        sg.ReadButton('Program 1'),
        sg.ReadButton('Program 2'),
        sg.ReadButton('Program 3', button_color=('white', '#35008B')),
        sg.Button('EXIT', button_color=('white', 'firebrick3'))
    ], [sg.T('', text_color='white', size=(50, 1), key='output')]]

    window = sg.Window('Floating Toolbar', no_titlebar=True,
                       keep_on_top=True).Layout(layout)

    # ---===--- Loop taking in user input and executing appropriate program --- #
    while True:
        (button, value) = window.Read()
        if button is 'EXIT' or button is None:
            break  # exit button clicked
        if button is 'Program 1':
            print('Run your program 1 here!')
        elif button is 'Program 2':
            print('Run your program 2 here!')
        elif button is 'Run':
            file = value['demofile']
            print('Launching %s' % file)
            ExecuteCommandSubprocess('python', os.path.join(ROOT_PATH, file))
        else:
            print(button)
def DownloadSubtitlesGUI():
    sg.ChangeLookAndFeel('Dark')

    combobox = sg.InputCombo(values=['',], size=(10,1), key='lang')
    layout =  [
                [sg.Text('Subtitle Grabber', size=(40, 1), font=('Any 15'))],
                [sg.T('YouTube Link'),sg.In(default_text='',size=(60,1), key='link', do_not_clear=True) ],
                [sg.Output(size=(90,20), font='Courier 12')],
                [sg.ReadButton('Get List')],
                [sg.T('Language Code'), combobox, sg.ReadButton('Download')],
                [sg.Button('Exit', button_color=('white', 'firebrick3'))]
                ]

    window = sg.Window('Subtitle Grabber launcher', text_justification='r', default_element_size=(15,1), font=('Any 14')).Layout(layout)

    # ---===--- Loop taking in user input and using it to query HowDoI --- #
    while True:
        (button, gui) = window.Read()
        if button in ('EXIT', None):
            break           # exit button clicked
        link = gui['link']
        if button is 'Get List':
            print('Getting list of subtitles....')
            window.Refresh()
            command = [f'C:/Python/PycharmProjects/GooeyGUI/youtube-dl --list-subs {link}',]
            output = ExecuteCommandSubprocess(command, wait=True, quiet=True)
            lang_list = [o[:5].rstrip() for o in output.split('\n') if 'vtt' in o]
            lang_list = sorted(lang_list)
            combobox.Update(values=lang_list)
            print('Done')

        elif button is 'Download':
            lang = gui['lang']
            if lang is '':
                lang = 'en'
            print(f'Downloading subtitle for {lang}...')
            window.Refresh()
            command = (f'C:/Python/PycharmProjects/GooeyGUI/youtube-dl --sub-lang {lang} --write-sub {link}',)
            ExecuteCommandSubprocess(command, wait=True)
            print('Done')
예제 #12
0
    def __init__(self):

        self.deler = 0
        self.run_face = 0
        self.ledsign = 0
        self.recognizer = None
        self.detector = None

        self.datasets = "./datasets"
        self.face_number = "./face_number"
        self.trainer = "./trainer"

        self.button = None
        self.value = None
        self.font = 'Arial'
        self.layout = [[
            sg.Text('ID'),
            sg.Input(key='id', size=(10, 1)),
            sg.Text('Age'),
            sg.Input(key='age', size=(10, 1))
        ],
                       [
                           sg.Button('Import face', font=self.font),
                           sg.Button('Training model', font=self.font),
                           sg.Button('Recognize faces',
                                     key='first',
                                     font=self.font),
                           sg.Button('Clean up the model', font=self.font),
                           sg.Button('Clean up all data', font=self.font),
                       ], [sg.Output(size=(60, 8), font=self.font)],
                       [
                           sg.Button('exit', font=self.font),
                       ]]
        self.window = sg.Window('Face recognition system',
                                font=self.font,
                                layout=self.layout)
예제 #13
0
        setpoint.set(0.0, 0.0, 5.0, 0)

        _X_SIZE = 4
        _Y_SIZE = 4

        layout = [[
            sg.Graph(canvas_size=(400, 400),
                     graph_bottom_left=(-200, -200),
                     graph_top_right=(200, 200),
                     background_color='red',
                     key='graph',
                     enable_events=True,
                     drag_submits=True)
        ],
                  [
                      sg.Button("land", key="LAND"),
                      sg.Button("go up", key="UP"),
                      sg.Button("go down", key="DOWN")
                  ],
                  [
                      sg.InputText("45", key="YAW"),
                      sg.Button("SEND_YAW", key="SEND_YAW")
                  ]]
        window = sg.Window('Graph test', layout, finalize=True)
        graph = window['graph']

        oval1 = graph.draw_oval((-5, 0), (5, 50),
                                fill_color='purple',
                                line_color='purple')
        oval3 = graph.draw_oval((0, 5), (50, -5),
                                fill_color='purple',
예제 #14
0
          ],
          [
              sg.T('Inner Loop Count', size=(15, 1), justification='r'),
              sg.In(default_text='100',
                    size=(5, 1),
                    key='CountInner',
                    do_not_clear=True),
              sg.T('Delay'),
              sg.In(default_text='10',
                    key='TimeInner',
                    size=(5, 1),
                    do_not_clear=True),
              sg.T('ms')
          ],
          [
              sg.Button('Show', pad=((0, 0), 3), bind_return_key=True),
              sg.T('me the meters!')
          ]]

window = sg.Window('One-Line Progress Meter Demo').Layout(layout)

while True:
    button, values = window.Read()
    if button is None:
        break
    if button == 'Show':
        max_outer = int(values['CountOuter'])
        max_inner = int(values['CountInner'])
        delay_inner = int(values['TimeInner'])
        delay_outer = int(values['TimeOuter'])
        for i in range(max_outer):
예제 #15
0
            size=(100, 1),
            background_color='light green',
            pad=(0, (0, 20))),
]]
row = []
# -- Create primary color viewer window --
for i, color in enumerate(color_map):
    row.append(
        sg.RButton(color,
                   button_color=('black', color),
                   key=color,
                   tooltip=color_map[color]))
    if (i + 1) % 15 == 0:
        layout.append(row)
        row = []

window = sg.Window('Color Viewer', grab_anywhere=False,
                   font=('any 9')).Layout(layout)

# -- Event loop --
while True:
    b, v = window.Read()
    if b is None:
        break
    # -- Create a secondary window that shows white and black text on chosen color
    layout2 = [[
        sg.Button(b, button_color=('white', b), tooltip=color_map[b]),
        sg.Button(b, button_color=('black', b), tooltip=color_map[b])
    ]]
    sg.Window('Buttons with white and black text',
              keep_on_top=True).Layout(layout2).Read()
예제 #16
0
#!/usr/bin/env python
import sys
if sys.version_info[0] < 3:
    import PySimpleGUI27 as sg
else:
    import PySimpleGUI as sg

layout = [[sg.Text("Hold down a key")], [sg.Button("OK")]]

window = sg.Window("Realtime Keyboard Test",
                   return_keyboard_events=True,
                   use_default_focus=False).Layout(layout)

while True:
    button, value = window.ReadNonBlocking()

    if button == "OK":
        print(button, value, "exiting")
        break
    if button is not None:
        if len(button) == 1:
            print('%s - %s' % (button, ord(button)))
        else:
            print(button)
    elif value is None:
        break
예제 #17
0
              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')),
              sg.Button('Exit', button_color=('white', '#00406B'))
          ]]

window = sg.Window("Disable Elements Demo",
                   default_element_size=(12, 1),
                   text_justification='r',
                   auto_size_text=False,
                   auto_size_buttons=False,
                   keep_on_top=True,
                   grab_anywhere=False,
                   default_button_element_size=(12,
                                                1)).Layout(layout).Finalize()

key_list = 'cbox', 'listbox', 'radio1', 'radio2', 'spin', 'option', 'combo', 'reset', 'notes', 'multi', 'slider'

for key in key_list:
예제 #18
0
def MediaPlayerGUI():
    background = '#F0F0F0'
    # Set the backgrounds the same as the background on the buttons
    sg.SetOptions(background_color=background,
                  element_background_color=background)
    # Images are located in a subfolder in the Demo Media Player.py folder
    image_pause = './ButtonGraphics/Pause.png'
    image_restart = './ButtonGraphics/Restart.png'
    image_next = './ButtonGraphics/Next.png'
    image_exit = './ButtonGraphics/Exit.png'

    # A text element that will be changed to display messages in the GUI

    # define layout of the rows
    layout = [[
        sg.Text('Media File Player', size=(17, 1), font=("Helvetica", 25))
    ], [sg.Text('', size=(15, 2), font=("Helvetica", 14), key='output')],
              [
                  sg.ReadButton('Restart Song',
                                button_color=(background, background),
                                image_filename=image_restart,
                                image_size=(50, 50),
                                image_subsample=2,
                                border_width=0),
                  sg.Text(' ' * 2),
                  sg.ReadButton('Pause',
                                button_color=(background, background),
                                image_filename=image_pause,
                                image_size=(50, 50),
                                image_subsample=2,
                                border_width=0),
                  sg.Text(' ' * 2),
                  sg.ReadButton('Next',
                                button_color=(background, background),
                                image_filename=image_next,
                                image_size=(50, 50),
                                image_subsample=2,
                                border_width=0),
                  sg.Text(' ' * 2),
                  sg.Text(' ' * 2),
                  sg.Button('Exit',
                            button_color=(background, background),
                            image_filename=image_exit,
                            image_size=(50, 50),
                            image_subsample=2,
                            border_width=0)
              ], [sg.Text('_' * 20)], [sg.Text(' ' * 30)],
              [
                  sg.Slider(range=(-10, 10),
                            default_value=0,
                            size=(10, 20),
                            orientation='vertical',
                            font=("Helvetica", 15)),
                  sg.Text(' ' * 2),
                  sg.Slider(range=(-10, 10),
                            default_value=0,
                            size=(10, 20),
                            orientation='vertical',
                            font=("Helvetica", 15)),
                  sg.Text(' ' * 2),
                  sg.Slider(range=(-10, 10),
                            default_value=0,
                            size=(10, 20),
                            orientation='vertical',
                            font=("Helvetica", 15))
              ],
              [
                  sg.Text('   Bass', font=("Helvetica", 15), size=(9, 1)),
                  sg.Text('Treble', font=("Helvetica", 15), size=(7, 1)),
                  sg.Text('Volume', font=("Helvetica", 15), size=(7, 1))
              ]]

    # Open a form, note that context manager can't be used generally speaking for async forms
    window = sg.Window('Media File Player',
                       auto_size_text=True,
                       default_element_size=(20, 1),
                       font=("Helvetica", 25),
                       no_titlebar=True).Layout(layout)
    # Our event loop
    while (True):
        # Read the form (this call will not block)
        button, values = window.ReadNonBlocking()
        if button == 'Exit':
            break
        # If a button was pressed, display it on the GUI by updating the text element
        if button:
            window.FindElement('output').Update(button)
예제 #19
0
else:
    import PySimpleGUI as sg
'''
A chat window.  Add call to your send-routine, print the response and you're done
'''

sg.ChangeLookAndFeel('GreenTan')  # give our window a spiffy set of colors

layout = [[sg.Text('Your output will go here', size=(40, 1))],
          [sg.Output(size=(127, 30), font=('Helvetica 10'))],
          [
              sg.Multiline(size=(85, 5), enter_submits=True, key='query'),
              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('Chat window',
                   default_element_size=(30, 2),
                   font=('Helvetica', ' 13'),
                   default_button_element_size=(8, 2)).Layout(layout)

# ---===--- Loop taking in user input and using it  --- #
while True:
    (button, value) = window.Read()
    if button is 'SEND':
        query = value['query'].rstrip()
        # EXECUTE YOUR COMMAND HERE
        print('The command you entered was {}'.format(query))
    elif button is None or button is 'EXIT':  # quit if exit button or X
          'grey20', 'grey21', 'grey22', 'grey23', 'grey24', 'grey25', 'grey26', 'grey27', 'grey28',
          'grey29', 'grey30', 'grey31', 'grey32', 'grey33', 'grey34', 'grey35', 'grey36', 'grey37',
          'grey38', 'grey39', 'grey40', 'grey42', 'grey43', 'grey44', 'grey45', 'grey46', 'grey47',
          'grey48', 'grey49', 'grey50', 'grey51', 'grey52', 'grey53', 'grey54', 'grey55', 'grey56',
          'grey57', 'grey58', 'grey59', 'grey60', 'grey61', 'grey62', 'grey63', 'grey64', 'grey65',
          'grey66', 'grey67', 'grey68', 'grey69', 'grey70', 'grey71', 'grey72', 'grey73', 'grey74',
          'grey75', 'grey76', 'grey77', 'grey78', 'grey79', 'grey80', 'grey81', 'grey82', 'grey83',
          'grey84', 'grey85', 'grey86', 'grey87', 'grey88', 'grey89', 'grey90', 'grey91', 'grey92',
          'grey93', 'grey94', 'grey95', 'grey97', 'grey98', 'grey99']

sg.SetOptions(button_element_size=(12,1), element_padding=(0,0), auto_size_buttons=False, border_width=0)

layout = [[sg.Text('Click on a color square to see both white and black text on that color', text_color='blue', font='Any 15')]]
row = []
# -- Create primary color viewer window --
for i, color in enumerate(COLORS):
    row.append(sg.RButton(color, button_color=('black', color), key=color))
    if (i+1) % 12 == 0:
        layout.append(row)
        row = []

window = sg.Window('Color Viewer', grab_anywhere=False, font=('any 9')).Layout(layout)

# -- Event loop --
while True:
    b, v = window.Read()
    if b is None:
        break
    # -- Create a secondary window that shows white and black text on chosen color
    layout2 =[[sg.Button(b, button_color=('white', b)), sg.Button(b, button_color=('black', b))] ]
    sg.Window('Buttons with white and black text', keep_on_top=True).Layout(layout2).Read()
예제 #21
0
                string += i.capitalize() + " "
        string = string[:-1]
        print string
    """

    window_layout = [[
        gui.Frame(
            "",
            layout=[[gui.Text("What if the past really defined the future?")],
                    [gui.Text("Press submit and find out! Keyword optional.")],
                    [
                        gui.InputText(default_text="",
                                      size=(54, 1),
                                      key="keyword",
                                      do_not_clear=True)
                    ], [gui.Button("Submit", size=(46, 2))],
                    [
                        gui.Multiline(default_text="",
                                      do_not_clear=True,
                                      size=(52, 10),
                                      key="output")
                    ]])
    ]]

    window_title = "News Predictor"
    window = gui.Window(window_title).Layout(window_layout)

    #indow.FindElement("error_box").Update(value=ERROR_MESSAGE, append=True)

    # Window positioning:
    event, values = window.Read(timeout=100)
]

window2 = sg.Window('Boyut Belirle', boyut)

event, values = window2.read()

en = int(values[0])
boy = int(values[1])

header = [
    [
        sg.Text(
            'Harf Girilmesini Istemediginiz\nKutucuklara "*" Karakterini Giriniz'
        )
    ],  #GUI
    [sg.Button('OLUSTURULAN BULMACAYI COZ')]
]

input_rows = [[sg.Input(size=(4, 4), pad=(0, 0)) for col in range(en)]
              for row in range(boy)]

layout = input_rows + header

window = sg.Window('KARE BULMACA', layout, font='Courier 12')
event, values = window.read()

satiratla = 0
basayaz = str(en) + ' ' + str(boy) + '\n'
yazilacak = '?'

dosyaismi = str(boy) + str(en) + '.txt'
예제 #23
0
파일: v4_fuzzy.py 프로젝트: piradata/wpg
        setpoint_vel.start()

        _X_SIZE = 4
        _Y_SIZE = 4

        layout = [[
            sg.Graph(canvas_size=(400, 400),
                     graph_bottom_left=(-200, -200),
                     graph_top_right=(200, 200),
                     background_color='red',
                     key='graph',
                     enable_events=True,
                     drag_submits=True)
        ],
                  [
                      sg.Button("land", key="LAND"),
                      sg.Button("go up", key="UP"),
                      sg.Button("go down", key="DOWN")
                  ],
                  [
                      sg.Button("ACTIVATE_FUZZY", key="ACTIVATE_FUZZY"),
                      sg.Button("DEACTIVATE_FUZZY", key="DEACTIVATE_FUZZY")
                  ],
                  [
                      sg.InputText("45", key="YAW"),
                      sg.Button("SEND_YAW", key="SEND_YAW")
                  ],
                  [
                      sg.InputText(KPx,
                                   size=(10, 10),
                                   tooltip="K_P",
예제 #24
0
		rospy.loginfo("Takeoff")
		setpoint_pos.set(0.0, 0.0, 2.0, wait=True)

		rospy.loginfo("## finalizing module of position control")
		setpoint_pos.finish()

		rospy.loginfo("## Initiating module of velocity control")
		setpoint_vel.init(0.0, 0.0, 2.0)
		setpoint_vel.start()

		_X_SIZE = 4
		_Y_SIZE = 4

		layout = [[sg.Graph(canvas_size=(400, 400), graph_bottom_left=(-200, -200), graph_top_right=(200, 200), background_color='red', key='graph', enable_events=True, drag_submits=True)],
		          [sg.Button("land", key="LAND"), sg.Button("go up", key="UP"), sg.Button("go down", key="DOWN")],
				  [sg.Button("ACTIVATE_FUZZY", key="ACTIVATE_FUZZY"), sg.Button("DEACTIVATE_FUZZY", key="DEACTIVATE_FUZZY")],
		          [sg.InputText("45", key="YAW"), sg.Button("SEND_YAW", key="SEND_YAW")],
		          [sg.InputText(KPx, size=(10,10), tooltip="K_P", key="K_P"),
				   sg.InputText(KIx, size=(10,10), tooltip="K_I", key="K_I"),
				   sg.InputText(KDx, size=(10,10), tooltip="K_D", key="K_D"), sg.Button("SEND_PID", key="SEND_PID")]]
		window = sg.Window('Drone control view', layout, finalize=True)
		graph = window['graph']

		oval1 = graph.draw_oval((-5, 0), (5, 50), fill_color='purple', line_color='purple')
		oval3 = graph.draw_oval((0, 5), (50, -5), fill_color='purple', line_color='purple')
		oval2 = graph.draw_oval((5, 0), (-5, -50), fill_color='blue', line_color='blue')
		oval4 = graph.draw_oval((0, -5), (-50, 5), fill_color='blue', line_color='blue')
		circleSize = 15
		circle = graph.draw_circle((0, 0), circleSize, fill_color='black', line_color='green')
예제 #25
0
#!/usr/bin/env python
import sys
if sys.version_info[0] < 3:
    import PySimpleGUI27 as sg
else:
    import PySimpleGUI as sg

# Recipe for getting keys, one at a time as they are released
# If want to use the space bar, then be sure and disable the "default focus"

layout = [[sg.Text("Press a key or scroll mouse")],
          [sg.Text("", size=(18, 1), key='text')], [sg.Button("OK", key='OK')]]

window = sg.Window("Keyboard Test",
                   return_keyboard_events=True,
                   use_default_focus=False).Layout(layout)

# ---===--- Loop taking in user input --- #
while True:
    button, value = window.Read()
    text_elem = window.FindElement('text')
    if button in ("OK", None):
        print(button, "exiting")
        break
    if len(button) == 1:
        text_elem.Update(value='%s - %s' % (button, ord(button)))
    if button is not None:
        text_elem.Update(button)
예제 #26
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
예제 #27
0
]]], ['&Help', '&About']]

mainLayout = [
    [sg.Menu(menu_def, tearoff=True)],
    [sg.Text("Account to send from:", size=(138, 1), justification="right")],
    [
        sg.Combo([
            "Create Payload", "Launch Payload", "Open shell",
            "Check Status of Clients", "Check Status of ProxyChains",
            "Single Account Checkup"
        ],
                 size=(100, 10),
                 enable_events=False,
                 readonly=True),
        sg.Listbox(values=(accounts.values()), size=(50, 20))
    ], [sg.Button("Execute", size=(20, 2), button_color=["red", "black"])],
    [sg.Text("Notes", size=(120, 2)),
     sg.Text("Target Client", size=(15, 2))],
    [
        sg.Multiline(autoscroll=True, size=(100, 10), do_not_clear=True),
        sg.Listbox(values=(clients.values()), size=(50, 10))
    ],
    [
        sg.Button("Save",
                  tooltip='Click to save notes for client',
                  button_color=["black", "white"]),
        sg.Button('Add Client', button_color=["black", "white"]),
        sg.Button('Add Module', button_color=["black", "white"]),
        sg.Button('Add Account', button_color=["black", "white"]),
        sg.Button("Clear", button_color=["black", "white"]),
        sg.Button('Exit', button_color=["black", "red"])