2018-09-28 18:57:37 +00:00
|
|
|
#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 #
|
|
|
|
# ---------------------------------#
|
|
|
|
#!/usr/bin/env python
|
|
|
|
import sys
|
2018-09-28 18:57:37 +00:00
|
|
|
if sys.version_info[0] >= 3:
|
2018-09-27 20:24:09 +00:00
|
|
|
import PySimpleGUI as sg
|
2018-09-28 18:57:37 +00:00
|
|
|
else:
|
|
|
|
import PySimpleGUI27 as sg
|
2018-09-27 20:24:09 +00:00
|
|
|
|
2018-09-29 17:48:48 +00:00
|
|
|
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(layout)
|
2018-10-15 20:07:23 +00:00
|
|
|
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
|
|
|
#!/usr/bin/env python
|
|
|
|
import sys
|
2018-09-28 18:57:37 +00:00
|
|
|
if sys.version_info[0] >= 3:
|
2018-09-27 20:24:09 +00:00
|
|
|
import PySimpleGUI as sg
|
2018-09-28 18:57:37 +00:00
|
|
|
else:
|
|
|
|
import PySimpleGUI27 as sg
|
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
|
|
|
|
2018-10-29 00:01:03 +00:00
|
|
|
window = sg.Window('My Window Title').Layout(layout)
|
2018-09-27 20:24:09 +00:00
|
|
|
|
2018-10-29 00:01:03 +00:00
|
|
|
while True: # Event Loop
|
2018-10-15 20:07:23 +00:00
|
|
|
event, values = window.Read()
|
2018-10-29 00:01:03 +00:00
|
|
|
if event is None: # if window closed with X
|
2018-09-29 17:48:48 +00:00
|
|
|
break
|
2018-10-15 20:07:23 +00:00
|
|
|
print(event, values)
|