Rework of Demo Debugger Integration + New Demo Debugger Button (experimental only)
This commit is contained in:
parent
fc4e99625c
commit
f2ac7d37bb
|
@ -0,0 +1,48 @@
|
||||||
|
import PySimpleGUI as sg
|
||||||
|
# import imwatchingyou # STEP 1
|
||||||
|
|
||||||
|
"""
|
||||||
|
Demo program that shows you how to integrate the PySimpleGUI Debugger
|
||||||
|
into your program.
|
||||||
|
This particular program is a GUI based program simply to make it easier for you to interact and change
|
||||||
|
things.
|
||||||
|
|
||||||
|
In this example, the debugger is not started initiallly. You click the "Debug" button to launch it
|
||||||
|
There are THREE steps, and they are copy and pastes.
|
||||||
|
1. At the top of your app to debug add
|
||||||
|
import imwatchingyou
|
||||||
|
2. When you want to show a debug window, call one of two functions:
|
||||||
|
imwatchingyou.show_debug_window()
|
||||||
|
imwatchingyou.show_popout_window()
|
||||||
|
3. You must find a location in your code to "refresh" the debugger. Some loop that's executed often.
|
||||||
|
In this loop add this call:
|
||||||
|
imwatchingyou.refresh()
|
||||||
|
"""
|
||||||
|
|
||||||
|
layout = [
|
||||||
|
[sg.T('A typical PSG application')],
|
||||||
|
[sg.In(key='_IN_')],
|
||||||
|
[sg.T(' ', key='_OUT_', size=(45,1))],
|
||||||
|
[sg.CBox('Checkbox 1'), sg.CBox('Checkbox 2')],
|
||||||
|
[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_')],
|
||||||
|
[sg.Output(size=(50,6))],
|
||||||
|
[sg.Ok(), sg.Exit(), sg.Button('Enable'), sg.Debug(key='Debug')],
|
||||||
|
]
|
||||||
|
|
||||||
|
window = sg.Window('This is your Application Window', layout, debugger_enabled=False)
|
||||||
|
|
||||||
|
counter = 0
|
||||||
|
timeout = 100
|
||||||
|
|
||||||
|
while True: # Your Event Loop
|
||||||
|
event, values = window.Read(timeout=timeout)
|
||||||
|
if event in (None, 'Exit'):
|
||||||
|
break
|
||||||
|
elif event == 'Enable':
|
||||||
|
window.EnableDebugger()
|
||||||
|
counter += 1
|
||||||
|
# to prove window is operating, show the input in another area in the window.
|
||||||
|
window.Element('_OUT_').Update(values['_IN_'])
|
||||||
|
|
||||||
|
window.Close()
|
|
@ -1,46 +1,60 @@
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
import PySimpleGUIdebugger # STEP 1
|
import imwatchingyou # STEP 1
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Demo program that shows you how to integrate the PySimpleGUI Debugger
|
Demo program that shows you how to integrate the PySimpleGUI Debugger
|
||||||
into your program.
|
into your program.
|
||||||
|
This particular program is a GUI based program simply to make it easier for you to interact and change
|
||||||
|
things.
|
||||||
|
|
||||||
In this example, the debugger is not started initiallly. You click the "Debug" button to launch it
|
In this example, the debugger is not started initiallly. You click the "Debug" button to launch it
|
||||||
There are THREE steps, and they are copy and pastes.
|
There are THREE steps, and they are copy and pastes.
|
||||||
1. At the top of your app to debug add
|
1. At the top of your app to debug add
|
||||||
import PySimpleGUIdebugger
|
import imwatchingyou
|
||||||
2. Initialize the debugger at the start of your program by calling:
|
2. When you want to show a debug window, call one of two functions:
|
||||||
PySimpleGUIdebugger.initialize()
|
imwatchingyou.show_debug_window()
|
||||||
3. At the top of your app's Event Loop add:
|
imwatchingyou.show_popout_window()
|
||||||
PySimpleGUIdebugger.refresh(locals(), globals())
|
3. You must find a location in your code to "refresh" the debugger. Some loop that's executed often.
|
||||||
|
In this loop add this call:
|
||||||
|
imwatchingyou.refresh()
|
||||||
"""
|
"""
|
||||||
|
|
||||||
layout = [
|
layout = [
|
||||||
[sg.T('A typical PSG application')],
|
[sg.T('A typical PSG application')],
|
||||||
[sg.In(key='_IN_')],
|
[sg.In(key='_IN_')],
|
||||||
[sg.T(' ', key='_OUT_')],
|
[sg.T(' ', key='_OUT_', size=(30, 1))],
|
||||||
[sg.Radio('a',1, key='_R1_'), sg.Radio('b',1, key='_R2_'), sg.Radio('c',1, key='_R3_')],
|
[sg.Radio('a', 1, key='_R1_'),
|
||||||
[sg.Combo(['c1', 'c2', 'c3'], size=(6,3), key='_COMBO_')],
|
sg.Radio('b', 1, key='_R2_'),
|
||||||
[sg.Output(size=(50,6))],
|
sg.Radio('c', 1, key='_R3_')],
|
||||||
[sg.Ok(), sg.Exit(), sg.B('Debug')],
|
[sg.Combo(['c1', 'c2', 'c3'], size=(6, 3), key='_COMBO_')],
|
||||||
]
|
[sg.Output(size=(50, 6))],
|
||||||
|
[sg.Ok(), sg.Exit(), sg.Button('Debugg'), sg.Button('Popout')],
|
||||||
|
]
|
||||||
|
|
||||||
window = sg.Window('This is your Application Window', layout)
|
window = sg.Window('This is your Application Window', layout)
|
||||||
|
|
||||||
counter = 0
|
counter = 0
|
||||||
timeout = 100
|
timeout = 100
|
||||||
debug_started = False
|
|
||||||
|
# Start the program with the popout window showing so you can immediately start debugging!
|
||||||
|
imwatchingyou.show_debugger_popout_window()
|
||||||
|
|
||||||
while True: # Your Event Loop
|
while True: # Your Event Loop
|
||||||
if debug_started:
|
|
||||||
debug_started = PySimpleGUIdebugger.refresh(locals(), globals()) # STEP 3 - refresh debugger
|
|
||||||
event, values = window.Read(timeout=timeout)
|
event, values = window.Read(timeout=timeout)
|
||||||
if event in (None, 'Exit'):
|
if event in (None, 'Exit'):
|
||||||
break
|
break
|
||||||
elif event == 'Ok':
|
elif event == 'Ok':
|
||||||
print('You clicked Ok.... this is where print output goes')
|
print('You clicked Ok.... this is where print output goes')
|
||||||
elif event == 'Debug' and not debug_started:
|
imwatchingyou.show_debugger_popout_window() # STEP 2 also
|
||||||
PySimpleGUIdebugger.initialize() # STEP 2
|
elif event == 'Debugg':
|
||||||
debug_started = True
|
imwatchingyou.show_debugger_window() # STEP 2
|
||||||
|
elif event == 'Popout':
|
||||||
|
imwatchingyou.show_debugger_popout_window() # STEP 2
|
||||||
counter += 1
|
counter += 1
|
||||||
|
# to prove window is operating, show the input in another area in the window.
|
||||||
window.Element('_OUT_').Update(values['_IN_'])
|
window.Element('_OUT_').Update(values['_IN_'])
|
||||||
|
|
||||||
|
# don't worry about the "state" of things, just call this function "frequently"
|
||||||
|
imwatchingyou.refresh_debugger() # STEP 3 - refresh debugger
|
||||||
|
|
||||||
window.Close()
|
window.Close()
|
||||||
|
|
Loading…
Reference in New Issue