|
1 | 1 | import PySimpleGUI as sg |
2 | | -import PySimpleGUIdebugger # STEP 1 |
| 2 | +import imwatchingyou # STEP 1 |
3 | 3 |
|
4 | 4 | """ |
5 | 5 | Demo program that shows you how to integrate the PySimpleGUI Debugger |
6 | 6 | into your program. |
| 7 | + This particular program is a GUI based program simply to make it easier for you to interact and change |
| 8 | + things. |
| 9 | +
|
7 | 10 | In this example, the debugger is not started initiallly. You click the "Debug" button to launch it |
8 | 11 | There are THREE steps, and they are copy and pastes. |
9 | 12 | 1. At the top of your app to debug add |
10 | | - import PySimpleGUIdebugger |
11 | | - 2. Initialize the debugger at the start of your program by calling: |
12 | | - PySimpleGUIdebugger.initialize() |
13 | | - 3. At the top of your app's Event Loop add: |
14 | | - PySimpleGUIdebugger.refresh(locals(), globals()) |
| 13 | + import imwatchingyou |
| 14 | + 2. When you want to show a debug window, call one of two functions: |
| 15 | + imwatchingyou.show_debug_window() |
| 16 | + imwatchingyou.show_popout_window() |
| 17 | + 3. You must find a location in your code to "refresh" the debugger. Some loop that's executed often. |
| 18 | + In this loop add this call: |
| 19 | + imwatchingyou.refresh() |
15 | 20 | """ |
16 | 21 |
|
17 | 22 | layout = [ |
18 | | - [sg.T('A typical PSG application')], |
19 | | - [sg.In(key='_IN_')], |
20 | | - [sg.T(' ', key='_OUT_')], |
21 | | - [sg.Radio('a',1, key='_R1_'), sg.Radio('b',1, key='_R2_'), sg.Radio('c',1, key='_R3_')], |
22 | | - [sg.Combo(['c1', 'c2', 'c3'], size=(6,3), key='_COMBO_')], |
23 | | - [sg.Output(size=(50,6))], |
24 | | - [sg.Ok(), sg.Exit(), sg.B('Debug')], |
25 | | - ] |
| 23 | + [sg.T('A typical PSG application')], |
| 24 | + [sg.In(key='_IN_')], |
| 25 | + [sg.T(' ', key='_OUT_', size=(30, 1))], |
| 26 | + [sg.Radio('a', 1, key='_R1_'), |
| 27 | + sg.Radio('b', 1, key='_R2_'), |
| 28 | + sg.Radio('c', 1, key='_R3_')], |
| 29 | + [sg.Combo(['c1', 'c2', 'c3'], size=(6, 3), key='_COMBO_')], |
| 30 | + [sg.Output(size=(50, 6))], |
| 31 | + [sg.Ok(), sg.Exit(), sg.Button('Debugg'), sg.Button('Popout')], |
| 32 | +] |
26 | 33 |
|
27 | 34 | window = sg.Window('This is your Application Window', layout) |
28 | 35 |
|
29 | 36 | counter = 0 |
30 | 37 | timeout = 100 |
31 | | -debug_started = False |
32 | 38 |
|
33 | | -while True: # Your Event Loop |
34 | | - if debug_started: |
35 | | - debug_started = PySimpleGUIdebugger.refresh(locals(), globals()) # STEP 3 - refresh debugger |
| 39 | +# Start the program with the popout window showing so you can immediately start debugging! |
| 40 | +imwatchingyou.show_debugger_popout_window() |
| 41 | + |
| 42 | +while True: # Your Event Loop |
36 | 43 | event, values = window.Read(timeout=timeout) |
37 | 44 | if event in (None, 'Exit'): |
38 | 45 | break |
39 | 46 | elif event == 'Ok': |
40 | 47 | print('You clicked Ok.... this is where print output goes') |
41 | | - elif event == 'Debug' and not debug_started: |
42 | | - PySimpleGUIdebugger.initialize() # STEP 2 |
43 | | - debug_started = True |
| 48 | + imwatchingyou.show_debugger_popout_window() # STEP 2 also |
| 49 | + elif event == 'Debugg': |
| 50 | + imwatchingyou.show_debugger_window() # STEP 2 |
| 51 | + elif event == 'Popout': |
| 52 | + imwatchingyou.show_debugger_popout_window() # STEP 2 |
44 | 53 | counter += 1 |
| 54 | + # to prove window is operating, show the input in another area in the window. |
45 | 55 | window.Element('_OUT_').Update(values['_IN_']) |
| 56 | + |
| 57 | + # don't worry about the "state" of things, just call this function "frequently" |
| 58 | + imwatchingyou.refresh_debugger() # STEP 3 - refresh debugger |
| 59 | + |
46 | 60 | window.Close() |
0 commit comments