2018-09-27 20:24:09 +00:00
|
|
|
#!/usr/bin/env python
|
2019-10-23 20:10:03 +00:00
|
|
|
import PySimpleGUI as sg
|
2018-08-29 13:10:19 +00:00
|
|
|
|
|
|
|
'''
|
2019-10-31 12:31:15 +00:00
|
|
|
A simple send/response chat window. Add call to your send-routine and print the response
|
|
|
|
If async responses can come in, then will need to use a different design that uses PySimpleGUI async design pattern
|
2018-08-29 13:10:19 +00:00
|
|
|
'''
|
|
|
|
|
2019-12-24 23:52:47 +00:00
|
|
|
sg.theme('GreenTan') # give our window a spiffy set of colors
|
2018-09-11 03:24:20 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
layout = [[sg.Text('Your output will go here', size=(40, 1))],
|
2019-10-31 12:31:15 +00:00
|
|
|
[sg.Output(size=(110, 20), font=('Helvetica 10'))],
|
2021-03-01 11:59:36 +00:00
|
|
|
[sg.Multiline(size=(70, 5), enter_submits=False, key='-QUERY-', do_not_clear=False),
|
2019-10-23 20:10:03 +00:00
|
|
|
sg.Button('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0]), bind_return_key=True),
|
|
|
|
sg.Button('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]]
|
2018-09-24 22:01:00 +00:00
|
|
|
|
2021-03-01 11:59:36 +00:00
|
|
|
window = sg.Window('Chat window', layout, font=('Helvetica', ' 13'), default_button_element_size=(8,2), use_default_focus=False)
|
2018-09-11 03:24:20 +00:00
|
|
|
|
2019-10-31 12:31:15 +00:00
|
|
|
while True: # The Event Loop
|
2019-10-23 20:10:03 +00:00
|
|
|
event, value = window.read()
|
2020-05-07 10:22:59 +00:00
|
|
|
if event in (sg.WIN_CLOSED, 'EXIT'): # quit if exit button or X
|
2019-10-31 12:31:15 +00:00
|
|
|
break
|
2019-06-26 15:09:42 +00:00
|
|
|
if event == 'SEND':
|
2019-10-31 12:31:15 +00:00
|
|
|
query = value['-QUERY-'].rstrip()
|
2018-09-11 03:24:20 +00:00
|
|
|
# EXECUTE YOUR COMMAND HERE
|
2021-03-01 11:59:36 +00:00
|
|
|
print('The command you entered was {}'.format(query), flush=True)
|
2019-10-31 12:31:15 +00:00
|
|
|
|
2021-03-01 11:59:36 +00:00
|
|
|
window.close()
|