Major demo refresh.. switched everything to new function names, new design patterns
Out with the old, in with the new!!
This commit is contained in:
parent
2a06683383
commit
a1f4c60271
68 changed files with 706 additions and 1863 deletions
21
Demo_Chat.py
21
Demo_Chat.py
|
@ -1,31 +1,28 @@
|
|||
import PySimpleGUI as sg
|
||||
import sys
|
||||
|
||||
'''
|
||||
A chat window. Add call to your send-routine, print the response and you're done
|
||||
'''
|
||||
|
||||
# ------- Make a new FlexForm ------- #
|
||||
sg.ChangeLookAndFeel('GreenTan') # give our form a spiffy set of colors
|
||||
sg.ChangeLookAndFeel('GreenTan') # give our window a spiffy set of colors
|
||||
|
||||
form = sg.FlexForm('Chat window', default_element_size=(30, 2), font=('Helvetica',' 13'), default_button_element_size=(8,2))
|
||||
|
||||
layout = [
|
||||
[sg.Text('Your output will go here', size=(40, 1))],
|
||||
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.ReadFormButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0]), bind_return_key=True),
|
||||
sg.SimpleButton('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]
|
||||
]
|
||||
form.Layout(layout)
|
||||
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) = form.Read()
|
||||
(button, value) = window.Read()
|
||||
if button is 'SEND':
|
||||
query = value['query'].rstrip()
|
||||
# EXECUTE YOUR COMMAND HERE
|
||||
print('The command you entered was {}'.format(query))
|
||||
elif button is None or button is 'EXIT': # quit if exit button or X
|
||||
break
|
||||
exit(69)
|
||||
sys.exit(69)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue