From 35a0995fcc8f4bae7c62a1ede89ec8cc6400abc0 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 30 Oct 2018 13:07:12 -0400 Subject: [PATCH] New Demo - Design pattern showing window that stays open and updates something --- Demo_Design_Pattern_Persistent_Window.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Demo_Design_Pattern_Persistent_Window.py diff --git a/Demo_Design_Pattern_Persistent_Window.py b/Demo_Design_Pattern_Persistent_Window.py new file mode 100644 index 00000000..cf8f3d21 --- /dev/null +++ b/Demo_Design_Pattern_Persistent_Window.py @@ -0,0 +1,23 @@ +# -------------------------------------# +# DESIGN PATTERN 2 - Persistent Window # +# Update a text field based on input # +# -------------------------------------# +import sys +if sys.version_info[0] >= 3: + import PySimpleGUI as sg +else: + import PySimpleGUI27 as sg + +layout = [[sg.Text('Your typed chars appear here:'), sg.Text('', key='_OUTPUT_') ], + [sg.Input(key='_IN_')], + [sg.Button('Show'), sg.Button('Exit')], + ] + +window = sg.Window('My new window').Layout(layout) + +while True: # Event Loop + event, values = window.Read() + if event is None or event == 'Exit': + break + if event == 'Show': # change the text "output" element to be the value of "input" element + window.FindElement('_OUTPUT_').Update(values['_IN_'])