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
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)
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('')
# redefine the chatbot text based progress bar with a graphical one chatterbot.utils.print_progress_bar = print_progress_bar chatbot = ChatBot('Ron Obvious', trainer='chatterbot.trainers.ChatterBotCorpusTrainer') # Train based on the english corpus chatbot.train("chatterbot.corpus.english") ################# GUI ################# layout = [[sg.Output(size=(80, 20))], [ sg.Multiline(size=(70, 5), enter_submits=True), sg.ReadButton('SEND', bind_return_key=True), sg.ReadButton('EXIT') ]] window = sg.Window('Chat Window', auto_size_text=True, default_element_size=(30, 2)).Layout(layout) # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # while True: button, (value, ) = window.Read() if button is not 'SEND': break string = value.rstrip() print(' ' + string)
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') while True: button, values = window.Read() print(button) # show it all again and get buttons
], [ sg.Radio('My first Radio! ', "RADIO1", default=True, size=(10, 1)), sg.Radio('My second Radio!', "RADIO1") ]], title='Options', title_color='red', relief=sg.RELIEF_SUNKEN, tooltip='Use these to set flags') ], [ sg.Multiline( default_text= 'This is the default Text should you decide not to type anything', size=(35, 3)), sg.Multiline(default_text='A second multi-line', size=(35, 3)) ], [ sg.InputCombo(('Combobox 1', 'Combobox 2'), size=(20, 1)), sg.Slider(range=(1, 100), orientation='h', size=(34, 20), default_value=85) ], [sg.InputOptionMenu(('Menu Option 1', 'Menu Option 2', 'Menu Option 3'))], [ sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(30, 3)), sg.Frame('Labelled Group', [[
], [ sg.T('Output:', pad=((3, 0), 0)), sg.T('', size=(44, 1), text_color='white', key='output') ], [ sg.CBox('Checkbox:', default=True, pad=((3, 0), 0), key='cbox'), sg.Listbox((1, 2, 3, 4), size=(8, 3), key='listbox'), sg.Radio('Radio 1', default=True, group_id='1', key='radio1'), sg.Radio('Radio 2', default=False, group_id='1', key='radio2') ], [ sg.Spin((1, 2, 3, 4), 1, key='spin'), sg.OptionMenu((1, 2, 3, 4), key='option'), sg.Combo(values=(1, 2, 3, 4), key='combo') ], [sg.Multiline('Multiline', size=(20, 3), key='multi')], [sg.Slider((1, 10), size=(20, 20), orientation='h', key='slider')], [ sg.ReadButton('Enable', button_color=('white', 'black')), sg.ReadButton('Disable', button_color=('white', 'black')), sg.ReadButton('Reset', button_color=('white', '#9B0023'), key='reset'), sg.ReadButton('Values', button_color=('white', 'springgreen4')), 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,
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
[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"]) ] ] #Sample Layouts
#!/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':
""" 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) window.Move(10, 10) # Main program loop: ========================================================== while 1 == 1: event, values = window.Read(timeout=100)