PySimpleGUI/DemoPrograms/Demo_Template.py

35 lines
887 B
Python
Raw Normal View History

#!/usr/bin/env python
import PySimpleGUI as sg
#
# Choose one of these are your starting point. Copy, paste, have fun
#
2018-09-27 20:24:09 +00:00
# ---------------------------------#
# DESIGN PATTERN 1 - Simple Window #
# ---------------------------------#
layout = [[ sg.Text('My layout') ],
2018-10-29 00:01:03 +00:00
[ sg.CloseButton('Next Window')]]
2018-09-27 20:24:09 +00:00
window = sg.Window('My window', layout)
event, values = window.read()
2018-09-27 20:24:09 +00:00
2018-10-29 00:01:03 +00:00
# --------------------------------------------------#
# DESIGN PATTERN 2 - Persistent Window (stays open) #
# --------------------------------------------------#
2018-09-27 20:24:09 +00:00
2018-10-29 00:01:03 +00:00
layout = [[ sg.Text('My Window') ],
[ sg.Button('Read The Window')]]
2018-09-27 20:24:09 +00:00
window = sg.Window('My Window Title', layout)
2018-09-27 20:24:09 +00:00
2018-10-29 00:01:03 +00:00
while True: # Event Loop
event, values = window.read()
if event == sg.WIN_CLOSED: # if window closed with X
break
print(event, values)
window.close()