From ab13bde0827a2503d637e8669277b2b02a299ce8 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 2 Nov 2018 13:32:36 -0400 Subject: [PATCH] New Demo Program --- Demo_Stdout.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Demo_Stdout.py diff --git a/Demo_Stdout.py b/Demo_Stdout.py new file mode 100644 index 00000000..1ad90090 --- /dev/null +++ b/Demo_Stdout.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python +import sys +if sys.version_info[0] >= 3: + import PySimpleGUI as sg +else: + import PySimpleGUI27 as sg + +""" + Demo program that reroutes stdout and stderr. + Type something in the input box and click Print + Whatever you typed is "printed" using a standard print statement + Use the Output Element in your window layout to reroute stdout + You will see the output of the print in the Output Element in the center of the window + +""" + + +layout = [ + [sg.Text('Type something in input field and click print')], + [sg.In()], + [sg.Output()], + [sg.Button('Print')] + ] + +window = sg.Window('Reroute stdout').Layout(layout) + +while True: # Event Loop + event, values = window.Read() + if event is None: + break + print('You typed: ', values[0])