Exemplo n.º 1
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
Exemplo n.º 2
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)
Exemplo n.º 3
0
 def __init__(self, title=__title__):
     sg.ChangeLookAndFeel("Reddit")
     self.layout = []
     self.transition = None
     self.title = title
     self.window = None
     self.close = None
     self.events = []
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)
Exemplo n.º 5
0
def main():
    global g_exit, g_response_time

    # start ping measurement thread
    thread = Thread(target=ping_thread, args=(None, ))
    thread.start()

    sg.ChangeLookAndFeel('Black')
    sg.SetOptions(element_padding=(0, 0))

    layout = [
        [
            sg.T('Ping times to Google.com', font='Any 12'),
            sg.Quit(pad=((100, 0), 0), button_color=('white', 'black'))
        ],
        [
            sg.Graph(CANVAS_SIZE, (0, 0), (SAMPLES, 500),
                     background_color='black',
                     key='graph')
        ],
    ]

    window = sg.Window('Canvas test',
                       grab_anywhere=True,
                       background_color='black',
                       no_titlebar=False,
                       use_default_focus=False).Layout(layout)

    graph = window.FindElement('graph')

    prev_response_time = None
    i = 0
    prev_x, prev_y = 0, 0
    while True:
        time.sleep(.2)

        button, values = window.ReadNonBlocking()
        if button == 'Quit' or values is None:
            break
        if g_response_time is None or prev_response_time == g_response_time:
            continue
        new_x, new_y = i, g_response_time[0]
        prev_response_time = g_response_time
        if i >= SAMPLES:
            graph.Move(-STEP_SIZE, 0)
            prev_x = prev_x - STEP_SIZE
        graph.DrawLine((prev_x, prev_y), (new_x, new_y), color='white')
        # window.FindElement('graph').DrawPoint((new_x, new_y), color='red')
        prev_x, prev_y = new_x, new_y
        i += STEP_SIZE if i < SAMPLES else 0

    # tell thread we're done. wait for thread to exit
    g_exit = True
    thread.join()
Exemplo n.º 6
0
def main():
    global g_exit, g_response_time
    # start ping measurement thread

    sg.ChangeLookAndFeel('Black')
    sg.SetOptions(element_padding=(0, 0))

    layout = [
        [
            sg.Quit(button_color=('white', 'black')),
            sg.T('', pad=((100, 0), 0), font='Any 15', key='output')
        ],
        [
            sg.Graph(CANVAS_SIZE, (0, 0), (SAMPLES, SAMPLE_MAX),
                     background_color='black',
                     key='graph')
        ],
    ]

    window = sg.Window('CPU Graph',
                       grab_anywhere=True,
                       keep_on_top=True,
                       background_color='black',
                       no_titlebar=True,
                       use_default_focus=False).Layout(layout)

    graph = window.FindElement('graph')
    output = window.FindElement('output')
    # start cpu measurement thread
    thread = Thread(target=CPU_thread, args=(None, ))
    thread.start()

    last_cpu = i = 0
    prev_x, prev_y = 0, 0
    while True:  # the Event Loop
        time.sleep(.5)
        button, values = window.ReadNonBlocking()
        if button == 'Quit' or values is None:  # always give ths user a way out
            break
        # do CPU measurement and graph it
        current_cpu = int(g_cpu_percent * 10)
        if current_cpu == last_cpu:
            continue
        output.Update(current_cpu / 10)  # show current cpu usage at top
        if current_cpu > SAMPLE_MAX:
            current_cpu = SAMPLE_MAX
        new_x, new_y = i, current_cpu
        if i >= SAMPLES:
            graph.Move(-STEP_SIZE, 0)  # shift graph over if full of data
            prev_x = prev_x - STEP_SIZE
        graph.DrawLine((prev_x, prev_y), (new_x, new_y), color='white')
        prev_x, prev_y = new_x, new_y
        i += STEP_SIZE if i < SAMPLES else 0
        last_cpu = current_cpu
Exemplo n.º 7
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)
Exemplo n.º 8
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('')
Exemplo n.º 9
0
def main():
    global g_exit, g_response_time

    layout = [[sg.T('Enter width, height of graph')],
              [sg.In(size=(6, 1)), sg.In(size=(6, 1))],
              [sg.Ok(), sg.Cancel()]]

    window = sg.Window('Enter graph size').Layout(layout)
    b,v = window.Read()
    if b is None or b == 'Cancel':
        sys.exit(69)
    w, h = int(v[0]), int(v[1])
    CANVAS_SIZE = (w,h)

    # start ping measurement thread

    sg.ChangeLookAndFeel('Black')
    sg.SetOptions(element_padding=(0,0))

    layout = [  [sg.Quit( button_color=('white','black'))],
               [sg.Graph(CANVAS_SIZE, (0,0), (SAMPLES,SAMPLE_MAX),background_color='black', key='graph')],]

    window = sg.Window('Canvas test', grab_anywhere=True, background_color='black', no_titlebar=False, use_default_focus=False).Layout(layout).Finalize()
    graph = window.FindElement('graph')

    prev_response_time = None
    i=0
    prev_x, prev_y = 0, 0
    graph_value = 250
    while True:
        # time.sleep(.2)
        button, values = window.ReadNonBlocking()
        if button == 'Quit' or values is None:
            break
        graph_offset = random.randint(-10, 10)
        graph_value = graph_value + graph_offset
        if graph_value > SAMPLE_MAX:
            graph_value = SAMPLE_MAX
        if graph_value < 0:
            graph_value = 0
        new_x, new_y = i, graph_value
        prev_value = graph_value
        if i >= SAMPLES:
            graph.Move(-STEP_SIZE,0)
            prev_x = prev_x - STEP_SIZE
        graph.DrawLine((prev_x, prev_y), (new_x, new_y), color='white')
        # window.FindElement('graph').DrawPoint((new_x, new_y), color='red')
        prev_x, prev_y = new_x, new_y
        i += STEP_SIZE if i < SAMPLES else 0
Exemplo n.º 10
0
def TestMenus():
    import PySimpleGUI as sg

    sg.ChangeLookAndFeel('LightGreen')
    sg.SetOptions(element_padding=(0, 0))

    # ------ Menu Definition ------ #
    menu_def = [
        ['File', ['Open', 'Save', 'Properties']],
        [
            'Edit',
            ['Paste', [
                'Special',
                'Normal',
            ], 'Undo'],
        ],
        ['Help', 'About...'],
    ]

    # ------ GUI Defintion ------ #
    layout = [[sg.Menu(menu_def, tearoff=True)], [sg.Output(size=(60, 20))],
              [sg.In('Test', key='input', do_not_clear=True)]]

    window = sg.Window("Windows-like program",
                       default_element_size=(12, 1),
                       auto_size_text=False,
                       auto_size_buttons=False,
                       default_button_element_size=(12, 1)).Layout(layout)

    # ------ Loop & Process button menu choices ------ #
    while True:
        button, values = window.Read()
        if button is None or button == 'Exit':
            return
        print('Button = ', button)
        # ------ Process menu choices ------ #
        if button == 'About...':
            sg.Popup('About this program', 'Version 1.0',
                     'PySimpleGUI rocks...')
        elif button == 'Open':
            filename = sg.PopupGetFile('file to open', no_window=True)
            print(filename)
        elif button == 'Properties':
            SecondForm()
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')
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 main():
    global g_interval, g_procs, g_exit

    # ----------------  Create Form  ----------------
    sg.ChangeLookAndFeel('Black')
    layout = [
        [
            sg.Text('',
                    size=(8, 1),
                    font=('Helvetica', 20),
                    text_color=sg.YELLOWS[0],
                    justification='center',
                    key='text')
        ],
        [
            sg.Text('',
                    size=(30, 8),
                    font=('Courier New', 12),
                    text_color='white',
                    justification='left',
                    key='processes')
        ],
        [
            sg.Exit(button_color=('white', 'firebrick4'), pad=((15, 0), 0)),
            sg.Spin([x + 1 for x in range(10)], 1, key='spin')
        ],
    ]

    window = sg.Window('CPU Utilization',
                       no_titlebar=True,
                       auto_size_buttons=False,
                       keep_on_top=True,
                       grab_anywhere=True).Layout(layout)

    # start cpu measurement thread
    thread = Thread(target=CPU_thread, args=(None, ))
    thread.start()
    # ----------------  main loop  ----------------
    while (True):
        # --------- Read and update window --------
        button, values = window.ReadNonBlocking()

        # --------- Do Button Operations --------
        if values is None or button == 'Exit':
            break
        try:
            g_interval = int(values['spin'])
        except:
            g_interval = 1

        # cpu_percent = psutil.cpu_percent(interval=interval)       # if don't wan to use a task
        cpu_percent = g_cpu_percent

        # let the GUI run ever 700ms regardless of CPU polling time. makes window be more responsive
        time.sleep(.7)

        display_string = ''
        if g_procs:
            # --------- Create list of top % CPU porocesses --------
            try:
                top = {proc.name(): proc.cpu_percent() for proc in g_procs}
            except:
                pass

            top_sorted = sorted(top.items(),
                                key=operator.itemgetter(1),
                                reverse=True)
            if top_sorted:
                top_sorted.pop(0)
            display_string = ''
            for proc, cpu in top_sorted:
                display_string += '{:2.2f} {}\n'.format(cpu / 10, proc)

        # --------- Display timer in window --------
        window.FindElement('text').Update('CPU {}'.format(cpu_percent))
        window.FindElement('processes').Update(display_string)

    # Broke out of main loop. Close the window.
    window.CloseNonBlocking()
    g_exit = True
    thread.join()
Exemplo n.º 14
0
#!/usr/bin/env python
import sys
if sys.version_info[0] < 3:
    import PySimpleGUI27 as sg
else:
    import PySimpleGUI as sg
"""
Demonstrates using a "tight" layout with a Dark theme.
Shows how button states can be controlled by a user application.  The program manages the disabled/enabled
states for buttons and changes the text color to show greyed-out (disabled) buttons
"""

sg.ChangeLookAndFeel('Dark')
sg.SetOptions(element_padding=(0, 0))

layout = [[
    sg.T('User:'******'User 1', 'User 2'), size=(20, 1)),
    sg.T('0', size=(8, 1))
],
          [
              sg.T('Customer:', pad=((3, 0), 0)),
              sg.OptionMenu(values=('Customer 1', 'Customer 2'), size=(20, 1)),
              sg.T('1', size=(8, 1))
          ],
          [
              sg.T('Notes:', pad=((3, 0), 0)),
              sg.In(size=(44, 1), background_color='white', text_color='black')
          ],
          [
              sg.ReadButton('Start',
Exemplo n.º 15
0
#!/usr/bin/env python
import sys
if sys.version_info[0] < 3:
    import PySimpleGUI27 as sg
else:
    import PySimpleGUI as sg

sg.ChangeLookAndFeel('BlueMono')

# Column layout
col = [[sg.Text('col Row 1', text_color='white', background_color='blue')],
       [sg.Text('col Row 2', text_color='white', background_color='blue'), sg.Input('col input 1')],
       [sg.Text('col Row 3', text_color='white', background_color='blue'), sg.Input('col input 2')]]
# Window layout
layout = [[sg.Listbox(values=('Listbox Item 1', 'Listbox Item 2', 'Listbox Item 3'),
                      select_mode=sg.LISTBOX_SELECT_MODE_MULTIPLE, size=(20, 3)),
           sg.Column(col, background_color='blue')],
          [sg.Input('Last input')],
          [sg.OK()]]

# Display the window and get values
button, values = sg.Window('Compact 1-line form with column').Layout(layout).Read()

sg.Popup(button, values, line_width=200)

Exemplo n.º 16
0
#!/usr/bin/env python
import sys
if sys.version_info[0] < 3:
    import PySimpleGUI27 as sg
else:
    import PySimpleGUI as sg

import psutil

# ----------------  Create Form  ----------------
sg.ChangeLookAndFeel('Black')
layout = [[sg.Text('')],
          [
              sg.Text('',
                      size=(8, 2),
                      font=('Helvetica', 20),
                      justification='center',
                      key='text')
          ],
          [
              sg.Exit(button_color=('white', 'firebrick4'), pad=((15, 0), 0)),
              sg.Spin([x + 1 for x in range(10)], 1, key='spin')
          ]]
# Layout the rows of the form and perform a read. Indicate the form is non-blocking!
window = sg.Window('CPU Meter',
                   no_titlebar=True,
                   auto_size_buttons=False,
                   keep_on_top=True,
                   grab_anywhere=True).Layout(layout)

# ----------------  main loop  ----------------
Exemplo n.º 17
0
def PopupChooseFile(text_message):
    sg.ChangeLookAndFeel("Reddit")
    filename = sg.PopupGetFile(text_message)
    return filename
Exemplo n.º 18
0
#!/usr/bin/env python
import sys
if sys.version_info[0] < 3:
    import PySimpleGUI27 as sg
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':
Exemplo n.º 19
0
    'Unicode Minus': UnicodeMinus,
    'Pyplot Scales': PyplotScales,
    'Axes Grid': AxesGrid,
    'Exploring Normalizations': ExploringNormalizations,
    'Different Scales': DifferentScales,
    'Pyplot Box Plot': PyplotBoxPlot,
    'Pyplot ggplot Style Sheet': PyplotGGPlotSytleSheet,
    'Pyplot Line Poly Collection': PyplotLinePolyCollection,
    'Pyplot Line Styles': PyplotLineStyles,
    'Pyplot Scatter With Legend': PyplotScatterWithLegend,
    'Artist Customized Box Plots': PyplotArtistBoxPlots,
    'Artist Customized Box Plots 2': ArtistBoxplot2,
    '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'),
Exemplo n.º 20
0
    import PySimpleGUI27 as sg
else:
    import PySimpleGUI as sg

from chatterbot import ChatBot
import chatterbot.utils
'''
Demo_Chatterbot.py
A GUI wrapped arouind the Chatterbot package.
The GUI is used to show progress bars during the training process and 
to collect user input that is sent to the chatbot.  The reply is displayed in the GUI window
'''

# Create the 'Trainer GUI'
# The Trainer GUI consists of a lot of progress bars stacked on top of each other
sg.ChangeLookAndFeel('GreenTan')
sg.DebugWin()
MAX_PROG_BARS = 20  # number of training sessions
bars = []
texts = []
training_layout = [
    [sg.T('TRAINING PROGRESS', size=(20, 1), font=('Helvetica', 17))],
]
for i in range(MAX_PROG_BARS):
    bars.append(sg.ProgressBar(100, size=(30, 4)))
    texts.append(sg.T(' ' * 20, size=(20, 1), justification='right'))
    training_layout += [
        [texts[i], bars[i]],
    ]  # add a single row

training_window = sg.Window('Training').Layout(training_layout)
Exemplo n.º 21
0
def Everything():
    sg.ChangeLookAndFeel('TanBlue')

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

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

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

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

        if button is 'SaveSettings':
            filename = sg.PopupGetFile('Save Settings',
                                       save_as=True,
                                       no_window=True)
            window.SaveToDisk(filename)
            # save(values)
        elif button is 'LoadSettings':
            filename = sg.PopupGetFile('Load Settings', no_window=True)
            window.LoadFromDisk(filename)
            # load(form)
        elif button in ['Exit', None]:
            break