2019-05-24 12:51:17 +00:00
|
|
|
import PySimpleGUI as sg
|
2019-05-25 15:43:11 +00:00
|
|
|
import PySimpleGUIdebugger # STEP 1
|
2019-05-24 12:51:17 +00:00
|
|
|
"""
|
|
|
|
Demo program that shows you how to integrate the PySimpleGUI Debugger
|
|
|
|
into your program.
|
2019-05-25 03:52:35 +00:00
|
|
|
There are THREE steps, and they are copy and pastes.
|
2019-05-24 12:51:17 +00:00
|
|
|
1. At the top of your app to debug add
|
2019-05-25 01:04:15 +00:00
|
|
|
import PySimpleGUIdebugger
|
2019-05-25 15:43:11 +00:00
|
|
|
2. Initialize the debugger at the start of your program by calling:
|
2019-05-25 03:52:35 +00:00
|
|
|
PySimpleGUIdebugger.initialize()
|
2019-05-25 15:43:11 +00:00
|
|
|
3. At the top of your app's Event Loop add:
|
2019-05-25 01:04:15 +00:00
|
|
|
PySimpleGUIdebugger.refresh(locals(), globals())
|
2019-05-24 12:51:17 +00:00
|
|
|
"""
|
|
|
|
|
2019-05-25 15:43:11 +00:00
|
|
|
PySimpleGUIdebugger.initialize() # STEP 2
|
2019-05-24 12:51:17 +00:00
|
|
|
|
|
|
|
layout = [
|
|
|
|
[sg.T('A typical PSG application')],
|
|
|
|
[sg.In(key='_IN_')],
|
|
|
|
[sg.T(' ', key='_OUT_')],
|
|
|
|
[sg.Radio('a',1, key='_R1_'), sg.Radio('b',1, key='_R2_'), sg.Radio('c',1, key='_R3_')],
|
|
|
|
[sg.Combo(['c1', 'c2', 'c3'], size=(6,3), key='_COMBO_')],
|
2019-05-25 03:52:35 +00:00
|
|
|
[sg.Output(size=(50,6))],
|
2019-05-24 12:51:17 +00:00
|
|
|
[sg.Ok(), sg.Exit()],
|
|
|
|
]
|
|
|
|
|
|
|
|
window = sg.Window('This is your Application Window', layout)
|
|
|
|
# Variables that we'll use to demonstrate the debugger's features
|
|
|
|
counter = 0
|
|
|
|
timeout = 100
|
|
|
|
|
2019-05-25 16:09:37 +00:00
|
|
|
while True: # Your Event Loop
|
2019-05-25 15:43:11 +00:00
|
|
|
PySimpleGUIdebugger.refresh(locals(), globals()) # STEP 3 - refresh debugger
|
2019-05-24 12:51:17 +00:00
|
|
|
event, values = window.Read(timeout=timeout)
|
|
|
|
if event in (None, 'Exit'):
|
|
|
|
break
|
2019-05-25 03:52:35 +00:00
|
|
|
elif event == 'Ok':
|
|
|
|
print('You clicked Ok.... this is where print output goes')
|
2019-05-24 12:51:17 +00:00
|
|
|
counter += 1
|
2019-05-25 16:09:37 +00:00
|
|
|
window.Element('_OUT_').Update(values['_IN_'])
|
|
|
|
window.Close()
|