2018-09-27 20:24:09 +00:00
|
|
|
#!/usr/bin/env python
|
2018-09-24 22:01:00 +00:00
|
|
|
import sys
|
2018-09-28 18:57:37 +00:00
|
|
|
if sys.version_info[0] >= 3:
|
2018-09-27 20:24:09 +00:00
|
|
|
import PySimpleGUI as sg
|
2018-09-28 18:57:37 +00:00
|
|
|
else:
|
|
|
|
import PySimpleGUI27 as sg
|
2018-08-29 13:10:19 +00:00
|
|
|
|
|
|
|
'''
|
2018-09-11 03:24:20 +00:00
|
|
|
A chat window. Add call to your send-routine, print the response and you're done
|
2019-04-05 15:41:53 +00:00
|
|
|
|
|
|
|
To see this program RUN on the web go here:
|
|
|
|
https://repl.it/@PySimpleGUI/Chat-Application-Demo
|
|
|
|
|
|
|
|
Note that the size of the display on repl.it is smaller than most, so the sizes of the
|
|
|
|
Multiline and Output text areas were reduced in the online version. Nothing else was changed
|
2018-08-29 13:10:19 +00:00
|
|
|
'''
|
|
|
|
|
2018-09-24 22:01:00 +00:00
|
|
|
sg.ChangeLookAndFeel('GreenTan') # give our window a spiffy set of colors
|
2018-09-11 03:24:20 +00:00
|
|
|
|
2019-04-06 00:26:05 +00:00
|
|
|
layout = [ [sg.Text('Your output will go here', size=(40, 1))],
|
2018-09-11 03:24:20 +00:00
|
|
|
[sg.Output(size=(127, 30), font=('Helvetica 10'))],
|
|
|
|
[sg.Multiline(size=(85, 5), enter_submits=True, key='query'),
|
2019-04-06 00:26:05 +00:00
|
|
|
sg.Button('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0]), bind_return_key=True),
|
2018-09-24 22:01:00 +00:00
|
|
|
sg.Button('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]]
|
|
|
|
|
2019-04-05 15:41:53 +00:00
|
|
|
window = sg.Window('Chat window',
|
|
|
|
default_element_size=(30, 2),
|
|
|
|
font=('Helvetica',' 13'),
|
|
|
|
default_button_element_size=(8,2)).Layout(layout)
|
2018-09-11 03:24:20 +00:00
|
|
|
|
|
|
|
# ---===--- Loop taking in user input and using it --- #
|
|
|
|
while True:
|
2019-04-06 00:26:05 +00:00
|
|
|
event, value = window.Read()
|
2018-10-15 20:07:23 +00:00
|
|
|
if event is 'SEND':
|
2018-09-11 03:24:20 +00:00
|
|
|
query = value['query'].rstrip()
|
|
|
|
# EXECUTE YOUR COMMAND HERE
|
|
|
|
print('The command you entered was {}'.format(query))
|
2019-04-05 15:41:53 +00:00
|
|
|
elif event in (None, 'EXIT'): # quit if exit button or X
|
2018-09-11 03:24:20 +00:00
|
|
|
break
|
2018-09-24 22:01:00 +00:00
|
|
|
sys.exit(69)
|
2018-08-29 13:10:19 +00:00
|
|
|
|