示例#1
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
示例#2
0
def start_app():
    layout = [[
        sg.Text('Enter the last four of your phone number',
                size=(75, 1),
                justification='center',
                font=("Helvetica", 18))
    ],
              [
                  sg.Text('', size=(35, 1)),
                  sg.InputText(font=("Helvetica", 18),
                               justification='center',
                               size=(30, 1),
                               key='input_box')
              ],
              [
                  sg.Text('', size=(35, 1)),
                  sg.ReadButton('Submit'),
                  sg.Text('', size=(18, 1)),
                  sg.ReadButton('Clear')
              ], [sg.Exit(key='Exit')]]

    window = sg.Window('Log In/Out',
                       auto_size_buttons=False,
                       return_keyboard_events=True).Layout(layout)

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

        if button == 'Exit' or values is None:
            break
        elif button == 'Clear':
            element = window.FindElement('input_box')
            element.Update('')
        elif button == 'Submit' or ord(str(button)) == 13:
            phone_number = values['input_box']
            try:
                int(phone_number)
                if int(phone_number) > 9999:
                    sg.Popup('Enter last four of your phone number.')
                elif len(phone_number) < 4:
                    sg.Popup('Enter last four of your phone number.')
                else:
                    failed = fetch_user(phone_number)
                    if failed:
                        sg.Popup('Invalid phone number.')

                    element = window.FindElement('input_box')
                    element.Update('')
            except:
                sg.Popup('Number values only.')
                element = window.FindElement('input_box')
                element.Update('')
示例#3
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('')
示例#4
0
def RemoteControlExample_NoGraphics():
    # Make a form, but don't use context manager

    layout = [[sg.Text('Robotics Remote Control', justification='center')],
              [sg.T('', justification='center', size=(19, 1), key='status')],
              [sg.T(' ' * 8), sg.RealtimeButton('Forward')],
              [
                  sg.RealtimeButton('Left'),
                  sg.T('              '),
                  sg.RealtimeButton('Right')
              ], [sg.T(' ' * 8), sg.RealtimeButton('Reverse')], [sg.T('')],
              [sg.Quit(button_color=('black', 'orange'))]]
    # Display form to user
    window = sg.Window('Robotics Remote Control',
                       auto_size_text=True,
                       grab_anywhere=False).Layout(layout)

    #
    # Some place later in your code...
    # You need to perform a ReadNonBlocking on your form every now and then or
    # else it won't refresh.
    #
    # your program's main loop
    while (True):
        # This is the code that reads and updates your window
        button, values = window.ReadNonBlocking()
        if button is not None:
            window.FindElement('status').Update(button)
        else:
            window.FindElement('status').Update('')
        # if user clicked quit button OR closed the form using the X, then break out of loop
        if button == 'Quit' or values is None:
            break

    window.CloseNonBlocking()
def RemoteControlExample():

    layout = [[sg.Text('Robotics Remote Control')],
              [sg.T(' ' * 10), sg.RealtimeButton('Forward')],
              [
                  sg.RealtimeButton('Left'),
                  sg.T(' ' * 15),
                  sg.RealtimeButton('Right')
              ], [sg.T(' ' * 10), sg.RealtimeButton('Reverse')], [sg.T('')],
              [sg.Quit(button_color=('black', 'orange'))]]

    window = sg.Window('Robotics Remote Control',
                       auto_size_text=True).Layout(layout).Finalize()

    #
    # Some place later in your code...
    # You need to perform a ReadNonBlocking on your window every now and then or
    # else it won't refresh.
    #
    # your program's main loop
    while (True):
        # This is the code that reads and updates your window
        button, values = window.ReadNonBlocking()
        if button is not None:
            print(button)
        if button == 'Quit' or values is None:
            break
        # time.sleep(.01)

    window.CloseNonBlocking()
示例#6
0
def creategui():
    sg.ChangeLookAndFeel('BlueMono')

    frame_layout = [
        [sg.T('Elapsed', size=(60, 1), key='-ELAPSED-')],
        [sg.Multiline('', size=(60, 12), autoscroll=True, key='-ML-')],
    ]

    # define the window layout
    layout = [[
        sg.Text('OMRON HVC P2 Demo GUI',
                size=(50, 1),
                justification='center',
                font='Helvetica 20')
    ], [sg.Image(filename='', key='image'),
        sg.Frame('Result', frame_layout)],
              [
                  sg.ReadButton('Exit',
                                size=(10, 1),
                                pad=((0, 0), 3),
                                font='Helvetica 14'),
                  sg.RButton('Pause',
                             key='-RUN-PAUSE-',
                             size=(10, 1),
                             font='Any 14')
              ]]

    # create the window and show it without the plot
    window = sg.Window('OMRON HVC P2 Demo Application', location=(400, 200))
    #window.Layout(layout).Finalize()
    window.Layout(layout)

    return window
示例#7
0
def GetFilesToCompare():
    form_rows = [[sg.Text('Enter 2 files to comare')],
                 [
                     sg.Text('File 1', size=(15, 1)),
                     sg.InputText(key='file1'),
                     sg.FileBrowse()
                 ],
                 [
                     sg.Text('File 2', size=(15, 1)),
                     sg.InputText(key='file2'),
                     sg.FileBrowse(target='file2')
                 ], [sg.Submit(), sg.Cancel()]]

    window = sg.Window('File Compare')
    button, values = window.Layout(form_rows).Read()
    return button, values
示例#8
0
def addClient():
    layout = [
        [sg.Text('Please enter the IP address and email')],
        [sg.Text('IP Address:', size=(15, 1)),
         sg.InputText('', key='_IP_')],
        [sg.Text('Email:', size=(15, 1)),
         sg.InputText('', key='_EMAIL_')], [sg.Submit(),
                                            sg.Cancel()]
    ]
    window = sg.Window('Add Account', layout)
    event, values = window.Read()
    window.Close()
    if (sg.PopupYesNo("Are you sure?") == "Yes"):
        return values
    else:
        pass
示例#9
0
def main():
    # filename = 'C:/Python/MIDIVideo/PlainVideos/- 08-30 Ted Talk/TED Talk Short - Video+.mp4'
    filename = sg.PopupGetFile('Filename to play')
    if filename is None:
        exit(69)
    vidFile = cv.VideoCapture(filename)
    # ---===--- Get some Stats --- #
    num_frames = vidFile.get(cv.CAP_PROP_FRAME_COUNT)
    fps = vidFile.get(cv.CAP_PROP_FPS)

    sg.ChangeLookAndFeel('Dark')

    # define the window layout
    layout = [[
        sg.Text('OpenCV Demo',
                size=(15, 1),
                pad=((510, 0), 3),
                justification='center',
                font='Helvetica 20')
    ], [sg.Image(filename='', key='image')],
              [
                  sg.Slider(range=(0, num_frames),
                            size=(115, 10),
                            orientation='h',
                            key='slider')
              ],
              [
                  sg.ReadButton('Exit',
                                size=(10, 2),
                                pad=((600, 0), 3),
                                font='Helvetica 14')
              ]]

    # create the window and show it without the plot
    window = sg.Window('Demo Application - OpenCV Integration',
                       no_titlebar=False,
                       location=(0, 0))
    window.Layout(layout)
    window.ReadNonBlocking()

    # ---===--- LOOP through video file by frame --- #
    i = 0
    temp_filename = next(tempfile._get_candidate_names()) + '.png'
    while vidFile.isOpened():
        button, values = window.ReadNonBlocking()
        if button is 'Exit' or values is None:
            os.remove(temp_filename)
            exit(69)
        ret, frame = vidFile.read()
        if not ret:  # if out of data stop looping
            break

        window.FindElement('slider').Update(i)
        i += 1

        with open(temp_filename, 'wb') as f:
            Image.fromarray(frame).save(temp_filename,
                                        'PNG')  # save the PIL image as file
            window.FindElement('image').Update(filename=temp_filename)
示例#10
0
def addAccount():  #add email account to the "Available" section
    layout = [[sg.Text('Please enter the email address and password')],
              [
                  sg.Text('Email Address:', size=(15, 1)),
                  sg.InputText('', key='_EMAIL_')
              ],
              [
                  sg.Text('Password:'******'', key='_PASSWORD_')
              ], [sg.Submit(), sg.Cancel()]]
    window = sg.Window('Add Account', layout)
    event, values = window.Read()
    window.Close()
    if (sg.PopupYesNo("Are you sure?") == "Yes"):
        return values
    else:
        pass
示例#11
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))
示例#12
0
def startup():
    layout = [[sg.Text('Please enter the name of your server:')],
              [sg.InputText()], [sg.Submit(), sg.Cancel()]]
    window = sg.Window('Project0', layout)
    event, values = window.Read()
    window.Close()
    ServerName = values[0]
    return ServerName
示例#13
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
def StatusOutputExample():
    # Create a text element that will be updated with status information on the GUI itself
    # Create the rows
    layout = [[sg.Text('Non-blocking GUI with updates')],
              [
                  sg.Text('',
                          size=(8, 2),
                          font=('Helvetica', 20),
                          justification='center',
                          key='output')
              ],
              [
                  sg.ReadButton('LED On'),
                  sg.ReadButton('LED Off'),
                  sg.ReadButton('Quit')
              ]]
    # Layout the rows of the Window and perform a read. Indicate the Window is non-blocking!
    window = sg.Window('Running Timer', auto_size_text=True).Layout(layout)

    #
    # Some place later in your code...
    # You need to perform a ReadNonBlocking on your window every now and then or
    # else it won't refresh.
    #
    # your program's main loop
    i = 0
    while (True):
        # This is the code that reads and updates your window
        button, values = window.ReadNonBlocking()
        window.FindElement('output').Update('{:02d}:{:02d}.{:02d}'.format(
            (i // 100) // 60, (i // 100) % 60, i % 100))
        if button == 'Quit' or values is None:
            break
        if button == 'LED On':
            print('Turning on the LED')
        elif button == 'LED Off':
            print('Turning off the LED')

        i += 1
        # Your code begins here
        time.sleep(.01)

    # Broke out of main loop. Close the window.
    window.CloseNonBlocking()
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)
示例#16
0
def RemoteControlExample():
    # Make a form, but don't use context manager
    sg.SetOptions(element_padding=(0, 0))
    back = '#eeeeee'
    image_forward = 'ButtonGraphics/RobotForward.png'
    image_backward = 'ButtonGraphics/RobotBack.png'
    image_left = 'ButtonGraphics/RobotLeft.png'
    image_right = 'ButtonGraphics/RobotRight.png'

    sg.SetOptions(border_width=0,
                  button_color=('black', back),
                  background_color=back,
                  element_background_color=back,
                  text_element_background_color=back)

    layout = [[sg.Text('Robotics Remote Control')],
              [sg.T('', justification='center', size=(19, 1), key='status')],
              [
                  sg.RealtimeButton('Forward',
                                    image_filename=image_forward,
                                    pad=((50, 0), 0))
              ],
              [
                  sg.RealtimeButton('Left', image_filename=image_left),
                  sg.RealtimeButton('Right',
                                    image_filename=image_right,
                                    pad=((50, 0), 0))
              ],
              [
                  sg.RealtimeButton('Reverse',
                                    image_filename=image_backward,
                                    pad=((50, 0), 0))
              ], [sg.T('')], [sg.Quit(button_color=('black', 'orange'))]]

    window = sg.Window('Robotics Remote Control',
                       auto_size_text=True,
                       grab_anywhere=False).Layout(layout)

    #
    # Some place later in your code...
    # You need to perform a ReadNonBlocking on your form every now and then or
    # else it won't refresh.
    #
    # your program's main loop
    while (True):
        # This is the code that reads and updates your window
        button, values = window.ReadNonBlocking()
        if button is not None:
            window.FindElement('status').Update(button)
        else:
            window.FindElement('status').Update('')
        # if user clicked quit button OR closed the form using the X, then break out of loop
        if button == 'Quit' or values is None:
            break

    window.CloseNonBlocking()
示例#17
0
def SecondForm():

    layout = [[
        sg.Text(
            'The second form is small \nHere to show that opening a window using a window works'
        )
    ], [sg.OK()]]

    window = sg.Window('Second Form').Layout(layout)
    b, v = window.Read()
示例#18
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)
示例#19
0
    def PlayerChooseSongGUI(self):

        # ---------------------- DEFINION OF CHOOSE WHAT TO PLAY GUI ----------------------------

        layout = [[
            sg.Text('MIDI File Player',
                    font=("Helvetica", 15),
                    size=(20, 1),
                    text_color='green')
        ], [sg.Text('File Selection', font=("Helvetica", 15), size=(20, 1))],
                  [
                      sg.Text('Single File Playback', justification='right'),
                      sg.InputText(size=(65, 1), key='midifile'),
                      sg.FileBrowse(size=(10, 1),
                                    file_types=(("MIDI files", "*.mid"), ))
                  ],
                  [
                      sg.Text('Or Batch Play From This Folder',
                              auto_size_text=False,
                              justification='right'),
                      sg.InputText(size=(65, 1), key='folder'),
                      sg.FolderBrowse(size=(10, 1))
                  ], [sg.Text('_' * 250, auto_size_text=False, size=(100, 1))],
                  [
                      sg.Text('Choose MIDI Output Device', size=(22, 1)),
                      sg.Listbox(values=self.PortList,
                                 size=(30, len(self.PortList) + 1),
                                 key='device')
                  ], [sg.Text('_' * 250, auto_size_text=False, size=(100, 1))],
                  [
                      sg.SimpleButton('PLAY',
                                      size=(12, 2),
                                      button_color=('red', 'white'),
                                      font=("Helvetica", 15),
                                      bind_return_key=True),
                      sg.Text(' ' * 2, size=(4, 1)),
                      sg.Cancel(size=(8, 2), font=("Helvetica", 15))
                  ]]

        window = sg.Window('MIDI File Player',
                           auto_size_text=False,
                           default_element_size=(30, 1),
                           font=("Helvetica", 12)).Layout(layout)
        self.Window = window
        return window.Read()
示例#20
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
示例#21
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 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')
示例#23
0
def CustomMeter():
    # layout the form
    layout = [[sg.Text('A custom progress meter')],
              [
                  sg.ProgressBar(10000,
                                 orientation='h',
                                 size=(20, 20),
                                 key='progress')
              ], [sg.Cancel()]]

    # create the form`
    window = sg.Window('Custom Progress Meter').Layout(layout)
    progress_bar = window.FindElement('progress')
    # loop that would normally do something useful
    for i in range(10000):
        # check to see if the cancel button was clicked and exit loop if clicked
        button, values = window.ReadNonBlocking()
        if button == 'Cancel' or values == None:
            break
        # update bar with loop value +1 so that bar eventually reaches the maximum
        progress_bar.UpdateBar(i + 1)
    # done with loop... need to destroy the window as it's still open
    window.CloseNonBlocking()
def main():
    global g_my_globals

    # define the form layout
    layout = [[
        sg.Text('Animated Ping',
                size=(40, 1),
                justification='center',
                font='Helvetica 20')
    ], [sg.Canvas(size=(640, 480), key='canvas')],
              [
                  sg.ReadButton('Exit',
                                size=(10, 2),
                                pad=((280, 0), 3),
                                font='Helvetica 14')
              ]]

    # create the form and show it without the plot
    window = sg.Window('Demo Application - Embedding Matplotlib In PySimpleGUI'
                       ).Layout(layout).Finalize()

    canvas_elem = window.FindElement('canvas')
    canvas = canvas_elem.TKCanvas

    fig = plt.figure()
    g_my_globals.axis_ping = fig.add_subplot(1, 1, 1)
    set_chart_labels()
    plt.tight_layout()

    while True:
        button, values = window.ReadNonBlocking()
        if button is 'Exit' or values is None:
            break

        run_a_ping_and_graph()
        photo = draw(fig, canvas)
示例#25
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
    sum = 0
    count = 0
    for hotel in common:
        count += 1
        predicted = final.loc[(final['Hotel_Address'] == hotel),
                              'New_Rate'].iat[0]
        actual = test.loc[(test['Hotel_Address'] == hotel), 'Rate'].iat[0]
        sum += math.pow(predicted - actual, 2)
    intermediate = sum / count
    rmse = math.sqrt(intermediate)
    return round(rmse, 6)


# the user interface to allow user input
layout = [
    [sg.Text('Where would you like to fly to?')],
    [
        sg.Text('User ID', size=(22, 1), tooltip='Input your User ID'),
        sg.InputText('')
    ],
    [
        sg.Text('Country/City Destination',
                size=(22, 1),
                tooltip='Where do you want to go?'),
        sg.InputText('')
    ],
    [
        sg.Text('Travel Type', size=(22, 1)),
        sg.InputCombo(
            ('Solo traveler', 'Couple', 'Group', 'Family with older children',
             'Family with young children'),
import Tkinter
import json
import re
import string
import random
import time
import sys
from Tkinter import *
import Pmw, sys
import PySimpleGUI27 as sg

boyut = [
    [sg.Text('Boyut Seciniz')],  #GUI
    [
        sg.Text('Row Sayisi', size=(15, 1)),
        sg.InputText(size=(15, 1)),
    ],
    [
        sg.Text('Col Sayisi', size=(15, 1)),
        sg.InputText(size=(15, 1)),
    ],
    [sg.Submit('BULMACA OLUSTUR')]
]

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

event, values = window2.read()

en = int(values[0])
boy = int(values[1])
示例#28
0
import PySimpleGUI27 as sg
import params

# Initiation
activity = 0
CDR = 0

sg.change_look_and_feel('BlueMono')  # Add some color to the window

# Very basic window.  Return values using auto numbered keys

layout = [
    [sg.Text('Enter the parameters to run the models:', size=(35, 1))],
    [
        sg.Drop(values=('Tea Preparation Activity', 'Washing Hands Activity',
                        'Dressing Activity'),
                auto_size_text=True)
    ],  #0
    [
        sg.Drop(values=('MCI', 'Mild AD', 'Moderate AD', 'Severe AD'),
                auto_size_text=True)
    ],  #1
    [sg.Text('# People', size=(20, 1)),
     sg.InputText()],  #2
    [sg.Text('Advanced parameters for the Declarative Memory Module:')],
    [
        sg.Text('Chunk Activation Transitory Noise e:', size=(30, 1)),
        sg.InputText()
    ],  #3
    [sg.Text('Strength of Association S:', size=(25, 1)),
     sg.InputText()],  # 4
    'Pyplot Histogram': PyplotHistogram
}

sg.ChangeLookAndFeel('LightGreen')
figure_w, figure_h = 650, 650
# define the form layout
listbox_values = [key for key in fig_dict.keys()]
col_listbox = [[
    sg.Listbox(values=listbox_values,
               change_submits=True,
               size=(28, len(listbox_values)),
               key='func')
], [sg.T(' ' * 12), sg.Exit(size=(5, 2))]]

layout = [
    [sg.Text('Matplotlib Plot Test', font=('current 18'))],
    [
        sg.Column(col_listbox, pad=(5, (3, 330))),
        sg.Canvas(size=(figure_w, figure_h), key='canvas'),
        sg.Multiline(size=(70, 35), pad=(5, (3, 90)), key='multiline')
    ],
]

# create the form and show it without the plot
window = sg.Window('Demo Application - Embedding Matplotlib In PySimpleGUI',
                   grab_anywhere=False).Layout(layout)
window.Finalize()

canvas_elem = window.FindElement('canvas')
multiline_elem = window.FindElement('multiline')
#!/usr/bin/env python
import sys
if sys.version_info[0] < 3:
    import PySimpleGUI27 as sg
else:
    import PySimpleGUI as sg
"""
    Simple Form showing how to use keys on your input fields
"""

layout = [[sg.Text('Please enter your Name, Address, Phone')],
          [sg.Text('Name', size=(15, 1)),
           sg.InputText('1', key='name')],
          [sg.Text('Address', size=(15, 1)),
           sg.InputText('2', key='address')],
          [sg.Text('Phone', size=(15, 1)),
           sg.InputText('3', key='phone')], [sg.Submit(),
                                             sg.Cancel()]]

window = sg.Window('Simple Data Entry Window').Layout(layout)
button, values = window.Read()

sg.Popup(button, values, values['name'], values['address'], values['phone'])