Skip to content

Commit

Permalink
Merge pull request #5 from PySimpleGUI/dev-latest
Browse files Browse the repository at this point in the history
Release 2.0
  • Loading branch information
MikeTheWatchGuy authored May 29, 2019
2 parents 676e32a + ec8a752 commit 48700c9
Show file tree
Hide file tree
Showing 3 changed files with 374 additions and 136 deletions.
31 changes: 19 additions & 12 deletions example_imwatching_you_use.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,46 @@
There are THREE steps, and they are copy and pastes.
1. At the top of your app to debug add
import imwatchingyou
2. Initialize the debugger at the start of your program by calling:
imwatchingyou.initialize()
3. At the top of your app's Event Loop add:
imwatchingyou.refresh(locals(), globals())
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_')],
[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.Combo(['c1', 'c2', 'c3'], size=(6,3), key='_COMBO_')],
[sg.Output(size=(50,6))],
[sg.Ok(), sg.Exit(), sg.B('Debug')],
[sg.Ok(), sg.Exit(), sg.Debugger(key='Debug')],
]

window = sg.Window('This is your Application Window', layout)

counter = 0
timeout = 100
debug_started = False

# Start the program with the popout window showing so you can immediately start debugging!
imwatchingyou.show_popout_window()

while True: # Your Event Loop
if debug_started:
debug_started = imwatchingyou.refresh(locals(), globals()) # STEP 3 - refresh debugger
event, values = window.Read(timeout=timeout)
if event in (None, 'Exit'):
break
elif event == 'Ok':
print('You clicked Ok.... this is where print output goes')
elif event == 'Debug' and not debug_started:
imwatchingyou.initialize() # STEP 2
debug_started = True
imwatchingyou.show_popout_window() # STEP 2 also
elif event == 'Debug':
imwatchingyou.show_debug_window() # STEP 2
counter += 1
# to prove window is operating, show the input in another area in the window.
window.Element('_OUT_').Update(values['_IN_'])

# don't worry about the "state" of things, just call this function "frequently"
imwatchingyou.refresh() # STEP 3 - refresh debugger

window.Close()
Loading

0 comments on commit 48700c9

Please sign in to comment.