PySimpleGUI/DemoPrograms/Demo_Stdout.py

29 lines
728 B
Python
Raw Normal View History

2018-11-02 17:32:36 +00:00
#!/usr/bin/env python
import PySimpleGUI as sg
2018-11-02 17:32:36 +00:00
"""
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.Input()],
[sg.Output()],
[sg.Button('Print')]
]
2018-11-02 17:32:36 +00:00
window = sg.Window('Reroute stdout', layout)
2018-11-02 17:32:36 +00:00
while True: # Event Loop
event, values = window.read()
2018-11-02 17:32:36 +00:00
if event is None:
break
print('You typed: ', values[0])
window.close()