commit
eca141f63f
|
@ -10,6 +10,7 @@ import signal
|
||||||
import psutil
|
import psutil
|
||||||
import operator
|
import operator
|
||||||
|
|
||||||
|
CONFIRM_KILLS = False
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Utility to show running processes, CPU usage and provides way to kill processes.
|
Utility to show running processes, CPU usage and provides way to kill processes.
|
||||||
|
@ -36,6 +37,17 @@ def kill_proc_tree(pid, sig=signal.SIGTERM, include_parent=True,
|
||||||
return (gone, alive)
|
return (gone, alive)
|
||||||
|
|
||||||
|
|
||||||
|
def show_list_by_name(window):
|
||||||
|
psutil.cpu_percent(interval=.1)
|
||||||
|
procs = psutil.process_iter()
|
||||||
|
all_procs = [[proc.cpu_percent(), proc.name(), proc.pid] for proc in procs]
|
||||||
|
sorted_by_cpu_procs = sorted(all_procs, key=operator.itemgetter(1), reverse=False)
|
||||||
|
display_list = []
|
||||||
|
for process in sorted_by_cpu_procs:
|
||||||
|
display_list.append('{:5d} {:5.2f} {}\n'.format(process[2], process[0] / 10, process[1]))
|
||||||
|
window.FindElement('_processes_').Update(display_list)
|
||||||
|
return display_list
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
# ---------------- Create Form ----------------
|
# ---------------- Create Form ----------------
|
||||||
|
@ -56,9 +68,10 @@ def main():
|
||||||
auto_size_buttons=False,
|
auto_size_buttons=False,
|
||||||
default_button_element_size=(12,1),
|
default_button_element_size=(12,1),
|
||||||
return_keyboard_events=True,
|
return_keyboard_events=True,
|
||||||
).Layout(layout)
|
).Layout(layout).Finalize()
|
||||||
|
|
||||||
display_list = None
|
|
||||||
|
display_list = show_list_by_name(window)
|
||||||
# ---------------- main loop ----------------
|
# ---------------- main loop ----------------
|
||||||
while (True):
|
while (True):
|
||||||
# --------- Read and update window --------
|
# --------- Read and update window --------
|
||||||
|
@ -72,25 +85,26 @@ def main():
|
||||||
|
|
||||||
# --------- Do Button Operations --------
|
# --------- Do Button Operations --------
|
||||||
if event == 'Sort by Name':
|
if event == 'Sort by Name':
|
||||||
psutil.cpu_percent(interval=1)
|
display_list = show_list_by_name(window)
|
||||||
procs = psutil.process_iter()
|
# psutil.cpu_percent(interval=.1)
|
||||||
all_procs = [[proc.cpu_percent(), proc.name(), proc.pid] for proc in procs]
|
# procs = psutil.process_iter()
|
||||||
sorted_by_cpu_procs = sorted(all_procs, key=operator.itemgetter(1), reverse=False)
|
# all_procs = [[proc.cpu_percent(), proc.name(), proc.pid] for proc in procs]
|
||||||
display_list = []
|
# sorted_by_cpu_procs = sorted(all_procs, key=operator.itemgetter(1), reverse=False)
|
||||||
for process in sorted_by_cpu_procs:
|
# display_list = []
|
||||||
display_list.append('{:5d} {:5.2f} {}\n'.format(process[2], process[0]/10, process[1]))
|
# for process in sorted_by_cpu_procs:
|
||||||
window.FindElement('_processes_').Update(display_list)
|
# display_list.append('{:5d} {:5.2f} {}\n'.format(process[2], process[0]/10, process[1]))
|
||||||
|
# window.FindElement('_processes_').Update(display_list)
|
||||||
elif event == 'Kill':
|
elif event == 'Kill':
|
||||||
processes_to_kill = values['_processes_']
|
processes_to_kill = values['_processes_']
|
||||||
for proc in processes_to_kill:
|
for proc in processes_to_kill:
|
||||||
pid = int(proc[0:5])
|
pid = int(proc[0:5])
|
||||||
if sg.PopupYesNo('About to kill {} {}'.format(pid, proc[12:]), keep_on_top=True) == 'Yes':
|
# if sg.PopupYesNo('About to kill {} {}'.format(pid, proc[12:]), keep_on_top=True) == 'Yes':
|
||||||
try:
|
try:
|
||||||
kill_proc_tree(pid=pid)
|
kill_proc_tree(pid=pid)
|
||||||
except:
|
except:
|
||||||
sg.PopupAutoClose('Error killing process', auto_close_duration=1)
|
sg.PopupNoWait('Error killing process', auto_close_duration=1, auto_close=True)
|
||||||
elif event == 'Sort by % CPU':
|
elif event == 'Sort by % CPU':
|
||||||
psutil.cpu_percent(interval=1)
|
psutil.cpu_percent(interval=.1)
|
||||||
procs = psutil.process_iter()
|
procs = psutil.process_iter()
|
||||||
all_procs = [[proc.cpu_percent(), proc.name(), proc.pid] for proc in procs]
|
all_procs = [[proc.cpu_percent(), proc.name(), proc.pid] for proc in procs]
|
||||||
sorted_by_cpu_procs = sorted(all_procs, key=operator.itemgetter(0), reverse=True)
|
sorted_by_cpu_procs = sorted(all_procs, key=operator.itemgetter(0), reverse=True)
|
||||||
|
|
487
PySimpleGUI.py
487
PySimpleGUI.py
|
@ -3699,6 +3699,25 @@ class Window:
|
||||||
CurrentRow = [] # start with a blank row and build up
|
CurrentRow = [] # start with a blank row and build up
|
||||||
# ------------------------- Add the elements to a row ------------------------- #
|
# ------------------------- Add the elements to a row ------------------------- #
|
||||||
for i, element in enumerate(args): # Loop through list of elements and add them to the row
|
for i, element in enumerate(args): # Loop through list of elements and add them to the row
|
||||||
|
if type(element) == list:
|
||||||
|
PopupError('Error creating layout',
|
||||||
|
'Layout has a LIST instead of an ELEMENT',
|
||||||
|
'This means you have a badly placed ]',
|
||||||
|
'The offensive list is:',
|
||||||
|
element,
|
||||||
|
'This list will be stripped from your layout'
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
elif callable(element):
|
||||||
|
PopupError('Error creating layout',
|
||||||
|
'Layout has a FUNCTION instead of an ELEMENT',
|
||||||
|
'This means you are missing () from your layout',
|
||||||
|
'The offensive list is:',
|
||||||
|
element,
|
||||||
|
'This item will be stripped from your layout'
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
|
||||||
element.Position = (CurrentRowNumber, i)
|
element.Position = (CurrentRowNumber, i)
|
||||||
element.ParentContainer = self
|
element.ParentContainer = self
|
||||||
CurrentRow.append(element)
|
CurrentRow.append(element)
|
||||||
|
@ -4264,12 +4283,18 @@ class Window:
|
||||||
self.TKroot.unbind("<ButtonRelease-1>")
|
self.TKroot.unbind("<ButtonRelease-1>")
|
||||||
self.TKroot.unbind("<B1-Motion>")
|
self.TKroot.unbind("<B1-Motion>")
|
||||||
|
|
||||||
|
def _callback_main_debugger_window_create_keystroke(self, event):
|
||||||
|
Debugger.debugger._build_main_debugger_window()
|
||||||
|
|
||||||
|
def _callback_popout_window_create_keystroke(self, event):
|
||||||
|
Debugger.debugger._build_floating_window()
|
||||||
|
|
||||||
def EnableDebugger(self):
|
def EnableDebugger(self):
|
||||||
self.TKroot.bind('<Cancel>', Debugger._build_main_debugger_window)
|
self.TKroot.bind('<Cancel>', self._callback_main_debugger_window_create_keystroke)
|
||||||
# root.bind('<Pause>', show_debugger_popout_window)
|
self.TKroot.bind('<Pause>', self._callback_popout_window_create_keystroke)
|
||||||
self.TKroot.bind('<Pause>', Debugger._build_floating_window)
|
|
||||||
self.DebuggerEnabled = True
|
self.DebuggerEnabled = True
|
||||||
|
|
||||||
|
|
||||||
def DisableDebugger(self):
|
def DisableDebugger(self):
|
||||||
self.TKroot.unbind("<Cancel>")
|
self.TKroot.unbind("<Cancel>")
|
||||||
self.TKroot.unbind("<Pause>")
|
self.TKroot.unbind("<Pause>")
|
||||||
|
@ -5411,7 +5436,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
|
||||||
element.TKEntry.bind('<Button-3>', element.RightClickMenuCallback)
|
element.TKEntry.bind('<Button-3>', element.RightClickMenuCallback)
|
||||||
# ------------------------- COMBOBOX element ------------------------- #
|
# ------------------------- COMBOBOX element ------------------------- #
|
||||||
elif element_type == ELEM_TYPE_INPUT_COMBO:
|
elif element_type == ELEM_TYPE_INPUT_COMBO:
|
||||||
max_line_len = max([len(str(l)) for l in element.Values])
|
max_line_len = max([len(str(l)) for l in element.Values]) if len(element.Values) else 0
|
||||||
if auto_size_text is False:
|
if auto_size_text is False:
|
||||||
width = element_size[0]
|
width = element_size[0]
|
||||||
else:
|
else:
|
||||||
|
@ -5477,7 +5502,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
|
||||||
if v == element.DefaultValue:
|
if v == element.DefaultValue:
|
||||||
element.TKCombo.current(i)
|
element.TKCombo.current(i)
|
||||||
break
|
break
|
||||||
else:
|
elif element.Values:
|
||||||
element.TKCombo.current(0)
|
element.TKCombo.current(0)
|
||||||
if element.ChangeSubmits:
|
if element.ChangeSubmits:
|
||||||
element.TKCombo.bind('<<ComboboxSelected>>', element.ComboboxSelectHandler)
|
element.TKCombo.bind('<<ComboboxSelected>>', element.ComboboxSelectHandler)
|
||||||
|
@ -6337,9 +6362,12 @@ def StartupTK(my_flex_form: Window):
|
||||||
root = tk.Toplevel()
|
root = tk.Toplevel()
|
||||||
|
|
||||||
if my_flex_form.DebuggerEnabled:
|
if my_flex_form.DebuggerEnabled:
|
||||||
root.bind('<Cancel>', Debugger._build_main_debugger_window)
|
root.bind('<Cancel>', my_flex_form._callback_main_debugger_window_create_keystroke)
|
||||||
# root.bind('<Pause>', show_debugger_popout_window)
|
root.bind('<Pause>', my_flex_form._callback_popout_window_create_keystroke)
|
||||||
root.bind('<Pause>', Debugger._build_floating_window)
|
my_flex_form.DebuggerEnabled = True
|
||||||
|
|
||||||
|
# root.bind('<Cancel>', Debugger._build_main_debugger_window)
|
||||||
|
# root.bind('<Pause>', Debugger._build_floating_window)
|
||||||
try:
|
try:
|
||||||
root.attributes('-alpha', 0) # hide window while building it. makes for smoother 'paint'
|
root.attributes('-alpha', 0) # hide window while building it. makes for smoother 'paint'
|
||||||
except:
|
except:
|
||||||
|
@ -7942,21 +7970,19 @@ WIDTH_VARIABLES = 23
|
||||||
WIDTH_RESULTS = 46
|
WIDTH_RESULTS = 46
|
||||||
|
|
||||||
WIDTH_WATCHER_VARIABLES = 20
|
WIDTH_WATCHER_VARIABLES = 20
|
||||||
WIDTH_WATCHER_RESULTS = 58
|
WIDTH_WATCHER_RESULTS = 60
|
||||||
|
|
||||||
WIDTH_LOCALS = 80
|
WIDTH_LOCALS = 80
|
||||||
NUM_AUTO_WATCH = 13
|
NUM_AUTO_WATCH = 9
|
||||||
|
|
||||||
|
MAX_LINES_PER_RESULT_FLOATING = 4
|
||||||
|
MAX_LINES_PER_RESULT_MAIN = 3
|
||||||
|
|
||||||
|
POPOUT_WINDOW_FONT = 'Sans 8'
|
||||||
|
|
||||||
class Debugger():
|
class Debugger():
|
||||||
watcher_window = None # type: Window
|
|
||||||
popout_window = None # type: Window
|
debugger = None
|
||||||
local_choices = {}
|
|
||||||
myrc = ''
|
|
||||||
custom_watch = ''
|
|
||||||
locals = {}
|
|
||||||
globals = {}
|
|
||||||
popout_choices = {}
|
|
||||||
|
|
||||||
# # ######
|
# # ######
|
||||||
## ## ## # # # # # ###### ##### # # #### #### ###### #####
|
## ## ## # # # # # ###### ##### # # #### #### ###### #####
|
||||||
|
@ -7966,11 +7992,23 @@ class Debugger():
|
||||||
# # # # # # ## # # # # # # # # # # # # # #
|
# # # # # # ## # # # # # # # # # # # # # #
|
||||||
# # # # # # # ###### ###### ##### #### #### #### ###### # #
|
# # # # # # # ###### ###### ##### #### #### #### ###### # #
|
||||||
|
|
||||||
# Includes the DUAL PANE! Don't forget REPL is there too!
|
def __init__(self):
|
||||||
def _build_main_debugger_window(self):
|
self.watcher_window = None # type: Window
|
||||||
if Debugger.watcher_window:
|
self.popout_window = None # type: Window
|
||||||
return
|
self.local_choices = {}
|
||||||
|
self.myrc = ''
|
||||||
|
self.custom_watch = ''
|
||||||
|
self.locals = {}
|
||||||
|
self.globals = {}
|
||||||
|
self.popout_choices = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def _build_main_debugger_window_callback(self, events):
|
||||||
|
self._build_main_debugger_window()
|
||||||
|
|
||||||
|
# Includes the DUAL PANE (now 2 tabs)! Don't forget REPL is there too!
|
||||||
|
def _build_main_debugger_window(self, location=(None, None)):
|
||||||
ChangeLookAndFeel(COLOR_SCHEME)
|
ChangeLookAndFeel(COLOR_SCHEME)
|
||||||
|
|
||||||
def InVar(key1):
|
def InVar(key1):
|
||||||
|
@ -7980,13 +8018,14 @@ class Debugger():
|
||||||
B('Obj', key=key1 + 'OBJ_'), ]
|
B('Obj', key=key1 + 'OBJ_'), ]
|
||||||
return row1
|
return row1
|
||||||
|
|
||||||
variables_frame = [InVar('_VAR1_'),
|
variables_frame = [InVar('_VAR0_'),
|
||||||
InVar('_VAR2_'),
|
InVar('_VAR1_'),
|
||||||
InVar('_VAR3_'), ]
|
InVar('_VAR2_'), ]
|
||||||
|
|
||||||
interactive_frame = [[T('>>> ', size=(9, 1), justification='r'), In(size=(83, 1), key='_INTERACTIVE_'),
|
interactive_frame = [[T('>>> '), In(size=(83, 1), key='_REPL_',
|
||||||
B('Go', bind_return_key=True, visible=False)],
|
tooltip='Type in any "expression" or "statement"\n and it will be disaplayed below.\nPress RETURN KEY instead of "Go"\nbutton for faster use'),
|
||||||
[T('CODE >>> ', justification='r', size=(9, 1)), In(size=(83, 1), key='_CODE_')],
|
B('Go', bind_return_key=True, visible=True)],
|
||||||
|
# [T('CODE >>> ', justification='r', size=(9, 1)), In(size=(83, 1), key='_CODE_', tooltip='Use for things like import or other statements / lines of code')],
|
||||||
[Multiline(size=(93, 26), key='_OUTPUT_', autoscroll=True, do_not_clear=True)], ]
|
[Multiline(size=(93, 26), key='_OUTPUT_', autoscroll=True, do_not_clear=True)], ]
|
||||||
|
|
||||||
autowatch_frame = [[Button('Choose Variables To Auto Watch', key='_LOCALS_'),
|
autowatch_frame = [[Button('Choose Variables To Auto Watch', key='_LOCALS_'),
|
||||||
|
@ -7994,14 +8033,21 @@ class Debugger():
|
||||||
Button('Show All Variables', key='_SHOW_ALL_'),
|
Button('Show All Variables', key='_SHOW_ALL_'),
|
||||||
Button('Locals', key='_ALL_LOCALS_'),
|
Button('Locals', key='_ALL_LOCALS_'),
|
||||||
Button('Globals', key='_GLOBALS_'),
|
Button('Globals', key='_GLOBALS_'),
|
||||||
Button('Popout', key='_POPOUT_')]] + \
|
Button('Popout', key='_POPOUT_')]]
|
||||||
[
|
|
||||||
[T('', size=(WIDTH_WATCHER_VARIABLES, 1), key='_WATCH%s_' % i),
|
variable_values = [[T('', size=(WIDTH_WATCHER_VARIABLES, 1), key='_WATCH%s_' % i),
|
||||||
T('', size=(WIDTH_WATCHER_RESULTS, 2), key='_WATCH%s_RESULT_' % i,
|
T('', size=(WIDTH_WATCHER_RESULTS, MAX_LINES_PER_RESULT_MAIN), key='_WATCH%s_RESULT_' % i,
|
||||||
auto_size_text=True)] for i in range(1, NUM_AUTO_WATCH + 1)]
|
)] for i in range(NUM_AUTO_WATCH)]
|
||||||
|
|
||||||
|
var_layout = []
|
||||||
|
for i in range(NUM_AUTO_WATCH):
|
||||||
|
var_layout.append([T('', size=(WIDTH_WATCHER_VARIABLES, 1), key='_WATCH%s_' % i),
|
||||||
|
T('', size=(WIDTH_WATCHER_RESULTS, MAX_LINES_PER_RESULT_MAIN), key='_WATCH%s_RESULT_' % i,
|
||||||
|
)])
|
||||||
|
|
||||||
col1 = [
|
col1 = [
|
||||||
[Frame('Auto Watches', autowatch_frame, title_color='blue')]
|
# [Frame('Auto Watches', autowatch_frame+variable_values, title_color='blue')]
|
||||||
|
[Frame('Auto Watches', autowatch_frame+var_layout, title_color='blue')]
|
||||||
]
|
]
|
||||||
|
|
||||||
col2 = [
|
col2 = [
|
||||||
|
@ -8009,15 +8055,15 @@ class Debugger():
|
||||||
[Frame('REPL-Light - Press Enter To Execute Commands', interactive_frame, title_color='blue'), ]
|
[Frame('REPL-Light - Press Enter To Execute Commands', interactive_frame, title_color='blue'), ]
|
||||||
]
|
]
|
||||||
|
|
||||||
layout = [[Pane([Column(col1), Column(col2)], size=(700, 640), orientation='h', background_color='red',
|
# Tab based layout
|
||||||
show_handle=True, ), ],
|
layout = [[TabGroup([[Tab('Variables', col1), Tab('REPL & Watches', col2)]])],
|
||||||
[Button('', image_data=red_x, key='_EXIT_', button_color=None),
|
[Button('', image_data=red_x, key='_EXIT_', button_color=None),]]
|
||||||
Text('Pull Red Line For REPL & Object Display Screen ---> ', size=(80, 1), justification='r')]]
|
|
||||||
|
|
||||||
window = Window("I'm Watching You Debugger", layout, icon=PSGDebugLogo, margins=(0, 0)).Finalize()
|
# ------------------------------- Create main window -------------------------------
|
||||||
|
window = Window("I'm Watching You Debugger", layout, icon=PSGDebugLogo, margins=(0, 0), location=location).Finalize()
|
||||||
window.Element('_VAR1_').SetFocus()
|
window.Element('_VAR1_').SetFocus()
|
||||||
Debugger.watcher_window = window
|
self.watcher_window = window
|
||||||
ChangeLookAndFeel('SystemDefault')
|
ChangeLookAndFeel('SystemDefault') # set look and feel to default before exiting
|
||||||
return window
|
return window
|
||||||
|
|
||||||
# # ####### #
|
# # ####### #
|
||||||
|
@ -8029,122 +8075,117 @@ class Debugger():
|
||||||
# # # # # # # ####### ## ###### # # # ####### #### #### #
|
# # # # # # # ####### ## ###### # # # ####### #### #### #
|
||||||
|
|
||||||
def _refresh_main_debugger_window(self, mylocals, myglobals):
|
def _refresh_main_debugger_window(self, mylocals, myglobals):
|
||||||
if not Debugger.watcher_window:
|
if not self.watcher_window: # if there is no window setup, nothing to do
|
||||||
return False
|
return False
|
||||||
event, values = Debugger.watcher_window.Read(timeout=1)
|
event, values = self.watcher_window.Read(timeout=1)
|
||||||
if event in (None, 'Exit', '_EXIT_'): # EXIT BUTTON / X BUTTON
|
if event in (None, 'Exit', '_EXIT_'): # EXIT BUTTON / X BUTTON
|
||||||
try:
|
try:
|
||||||
Debugger.watcher_window.Close()
|
self.watcher_window.Close()
|
||||||
except:
|
except: pass
|
||||||
pass
|
self.watcher_window = None
|
||||||
Debugger.watcher_window = None
|
|
||||||
return False
|
return False
|
||||||
|
# ------------------------------- Process events from REPL Tab -------------------------------
|
||||||
cmd_interactive = values['_INTERACTIVE_']
|
cmd = values['_REPL_'] # get the REPL entered
|
||||||
cmd_code = values['_CODE_']
|
# BUTTON - GO (NOTE - This button is invisible!!)
|
||||||
cmd = cmd_interactive or cmd_code
|
|
||||||
|
|
||||||
if event == 'Go': # GO BUTTON
|
if event == 'Go': # GO BUTTON
|
||||||
Debugger.watcher_window.Element('_INTERACTIVE_').Update('')
|
self.watcher_window.Element('_REPL_').Update('')
|
||||||
Debugger.watcher_window.Element('_CODE_').Update('')
|
self.watcher_window.Element('_OUTPUT_').Update(">>> {}\n".format(cmd), append=True, autoscroll=True)
|
||||||
Debugger.watcher_window.Element('_OUTPUT_').Update(">>> {}\n".format(cmd), append=True, autoscroll=True)
|
|
||||||
if cmd_interactive:
|
try:
|
||||||
expression = """ {} = {} """.format(fullname(Debugger.myrc), cmd)
|
result = eval('{}'.format(cmd), myglobals, mylocals)
|
||||||
|
except Exception as e:
|
||||||
try:
|
try:
|
||||||
exec(expression, myglobals, mylocals)
|
result = exec('{}'.format(cmd), myglobals, mylocals)
|
||||||
Debugger.watcher_window.Element('_OUTPUT_').Update('{}\n'.format(Debugger.myrc), append=True,
|
|
||||||
autoscroll=True)
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Debugger.watcher_window.Element('_OUTPUT_').Update('Exception {}\n'.format(e), append=True,
|
result = 'Exception {}\n'.format(e)
|
||||||
autoscroll=True)
|
|
||||||
else:
|
|
||||||
Debugger.watcher_window.Element('_CODE_').Update('')
|
|
||||||
Debugger.watcher_window.Element('_OUTPUT_').Update(">>> {}\n".format(cmd), append=True, autoscroll=True)
|
|
||||||
expression = """{}""".format(cmd)
|
|
||||||
try:
|
|
||||||
exec(expression, myglobals, mylocals)
|
|
||||||
Debugger.watcher_window.Element('_OUTPUT_').Update('{}\n'.format(cmd), append=True, autoscroll=True)
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
Debugger.watcher_window.Element('_OUTPUT_').Update('Exception {}\n'.format(e), append=True,
|
|
||||||
autoscroll=True)
|
|
||||||
|
|
||||||
|
self.watcher_window.Element('_OUTPUT_').Update('{}\n'.format(result), append=True, autoscroll=True)
|
||||||
|
# BUTTON - DETAIL
|
||||||
elif event.endswith('_DETAIL_'): # DETAIL BUTTON
|
elif event.endswith('_DETAIL_'): # DETAIL BUTTON
|
||||||
var = values['_VAR{}_'.format(event[4])]
|
var = values['_VAR{}_'.format(event[4])]
|
||||||
expression = """ {} = {} """.format(fullname(Debugger.myrc), var)
|
|
||||||
try:
|
try:
|
||||||
exec(expression, myglobals, mylocals)
|
result = str(eval(str(var), myglobals, mylocals))
|
||||||
PopupScrolled(str(values['_VAR{}_'.format(event[4])]) + '\n' + str(Debugger.myrc), title=var,
|
|
||||||
non_blocking=True)
|
|
||||||
except:
|
except:
|
||||||
pass
|
result = ''
|
||||||
|
PopupScrolled(str(values['_VAR{}_'.format(event[4])]) + '\n' + result, title=var, non_blocking=True)
|
||||||
|
# BUTTON - OBJ
|
||||||
elif event.endswith('_OBJ_'): # OBJECT BUTTON
|
elif event.endswith('_OBJ_'): # OBJECT BUTTON
|
||||||
var = values['_VAR{}_'.format(event[4])]
|
var = values['_VAR{}_'.format(event[4])]
|
||||||
expression = """ {} = {} """.format(fullname(Debugger.myrc), cmd)
|
|
||||||
try:
|
try:
|
||||||
exec(expression, myglobals, mylocals)
|
result = mylocals[var]
|
||||||
PopupScrolled(ObjToStringSingleObj(Debugger.myrc), title=var, non_blocking=True)
|
except Exception as e:
|
||||||
except:
|
result = '{} Error showing object {}'.format(e, var)
|
||||||
pass
|
PopupScrolled(str(var) + '\n' + ObjToStringSingleObj(result), title=var, non_blocking=True)
|
||||||
|
# PopupScrolled(str(var) + '\n' + result, title=var, non_blocking=True)
|
||||||
|
# ------------------------------- Process Watch Tab -------------------------------
|
||||||
|
# BUTTON - Choose Locals to see
|
||||||
elif event == '_LOCALS_': # Show all locals BUTTON
|
elif event == '_LOCALS_': # Show all locals BUTTON
|
||||||
self._choose_auto_watches(mylocals)
|
self._choose_auto_watches(mylocals)
|
||||||
|
# BUTTON - Locals (quick popup)
|
||||||
elif event == '_ALL_LOCALS_':
|
elif event == '_ALL_LOCALS_':
|
||||||
self._display_all_vars(mylocals)
|
self._display_all_vars(mylocals)
|
||||||
|
# BUTTON - Globals (quick popup)
|
||||||
elif event == '_GLOBALS_':
|
elif event == '_GLOBALS_':
|
||||||
self._display_all_vars(myglobals)
|
self._display_all_vars(myglobals)
|
||||||
|
# BUTTON - clear all
|
||||||
elif event == 'Clear All Auto Watches':
|
elif event == 'Clear All Auto Watches':
|
||||||
if PopupYesNo('Do you really want to clear all Auto-Watches?', 'Really Clear??') == 'Yes':
|
if PopupYesNo('Do you really want to clear all Auto-Watches?', 'Really Clear??') == 'Yes':
|
||||||
Debugger.local_choices = {}
|
self.local_choices = {}
|
||||||
Debugger.custom_watch = ''
|
self.custom_watch = ''
|
||||||
# Debugger.watcher_window.Element('_CUSTOM_WATCH_').Update('')
|
# BUTTON - Popout
|
||||||
elif event == '_POPOUT_':
|
elif event == '_POPOUT_':
|
||||||
if not Debugger.popout_window:
|
if not self.popout_window:
|
||||||
self._build_floating_window()
|
self._build_floating_window()
|
||||||
|
# BUTTON - Show All
|
||||||
elif event == '_SHOW_ALL_':
|
elif event == '_SHOW_ALL_':
|
||||||
for key in Debugger.locals:
|
for key in self.locals:
|
||||||
Debugger.local_choices[key] = True if not key.startswith('_') else False
|
self.local_choices[key] = not key.startswith('_')
|
||||||
|
|
||||||
# -------------------- Process the manual "watch list" ------------------
|
# -------------------- Process the manual "watch list" ------------------
|
||||||
for i in range(1, 4):
|
for i in range(3):
|
||||||
key = '_VAR{}_'.format(i)
|
key = '_VAR{}_'.format(i)
|
||||||
out_key = '_VAR{}_CHANGED_'.format(i)
|
out_key = '_VAR{}_CHANGED_'.format(i)
|
||||||
Debugger.myrc = ''
|
self.myrc = ''
|
||||||
if Debugger.watcher_window.Element(key):
|
if self.watcher_window.Element(key):
|
||||||
if values[key]:
|
var = values[key]
|
||||||
Debugger.watcher_window.Element(out_key).Update(values[key])
|
try:
|
||||||
else:
|
result = eval(str(var), myglobals, mylocals)
|
||||||
Debugger.watcher_window.Element(out_key).Update('')
|
except:
|
||||||
|
result = ''
|
||||||
|
self.watcher_window.Element(out_key).Update(str(result))
|
||||||
|
else:
|
||||||
|
self.watcher_window.Element(out_key).Update('')
|
||||||
|
|
||||||
# -------------------- Process the automatic "watch list" ------------------
|
# -------------------- Process the automatic "watch list" ------------------
|
||||||
slot = 1
|
slot = 0
|
||||||
for key in Debugger.local_choices:
|
for key in self.local_choices:
|
||||||
if Debugger.local_choices[key] is True:
|
if key == '_CUSTOM_WATCH_':
|
||||||
Debugger.watcher_window.Element('_WATCH{}_'.format(slot)).Update(key)
|
continue
|
||||||
|
if self.local_choices[key]:
|
||||||
|
self.watcher_window.Element('_WATCH{}_'.format(slot)).Update(key)
|
||||||
try:
|
try:
|
||||||
Debugger.watcher_window.Element('_WATCH{}_RESULT_'.format(slot)).Update(mylocals[key])
|
self.watcher_window.Element('_WATCH{}_RESULT_'.format(slot), silent_on_error=True).Update(mylocals[key])
|
||||||
except:
|
except:
|
||||||
pass
|
self.watcher_window.Element('_WATCH{}_RESULT_'.format(slot)).Update('')
|
||||||
# Debugger.watcher_window.Element('_WATCH{}_RESULT_'.format(slot)).Update('')
|
|
||||||
slot += 1
|
slot += 1
|
||||||
|
|
||||||
if slot + int(not Debugger.custom_watch in (None, '')) >= NUM_AUTO_WATCH:
|
if slot + int(not self.custom_watch in (None, '')) >= NUM_AUTO_WATCH:
|
||||||
break
|
break
|
||||||
|
# If a custom watch was set, display that value in the window
|
||||||
if Debugger.custom_watch:
|
if self.custom_watch:
|
||||||
Debugger.watcher_window.Element('_WATCH{}_'.format(slot)).Update(Debugger.custom_watch)
|
self.watcher_window.Element('_WATCH{}_'.format(slot)).Update(self.custom_watch)
|
||||||
try:
|
try:
|
||||||
Debugger.myrc = eval(Debugger.custom_watch, myglobals, mylocals)
|
self.myrc = eval(self.custom_watch, myglobals, mylocals)
|
||||||
except:
|
except:
|
||||||
Debugger.myrc = ''
|
self.myrc = ''
|
||||||
Debugger.watcher_window.Element('_WATCH{}_RESULT_'.format(slot)).Update(Debugger.myrc)
|
self.watcher_window.Element('_WATCH{}_RESULT_'.format(slot)).Update(self.myrc)
|
||||||
slot += 1
|
slot += 1
|
||||||
|
# blank out all of the slots not used (blank)
|
||||||
|
for i in range(slot, NUM_AUTO_WATCH):
|
||||||
|
self.watcher_window.Element('_WATCH{}_'.format(i)).Update('')
|
||||||
|
self.watcher_window.Element('_WATCH{}_RESULT_'.format(i)).Update('')
|
||||||
|
|
||||||
for i in range(slot, NUM_AUTO_WATCH + 1):
|
return True # return indicating the window stayed open
|
||||||
Debugger.watcher_window.Element('_WATCH{}_'.format(i)).Update('')
|
|
||||||
Debugger.watcher_window.Element('_WATCH{}_RESULT_'.format(i)).Update('')
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
###### # #
|
###### # #
|
||||||
# # #### ##### # # ##### # # # # # # ##### #### # #
|
# # #### ##### # # ##### # # # # # # ##### #### # #
|
||||||
|
@ -8161,6 +8202,7 @@ class Debugger():
|
||||||
# # # # # # ##### # ####### # # # # ###### ##### #
|
# # # # # # ##### # ####### # # # # ###### ##### #
|
||||||
# # # # # # # # # # # # # # # # # # # # #
|
# # # # # # # # # # # # # # # # # # # # #
|
||||||
###### #### # # # #### # # ###### ###### # # # # # ####
|
###### #### # # # #### # # ###### ###### # # # # # ####
|
||||||
|
# displays them into a single text box
|
||||||
|
|
||||||
def _display_all_vars(self, dict):
|
def _display_all_vars(self, dict):
|
||||||
num_cols = 3
|
num_cols = 3
|
||||||
|
@ -8185,21 +8227,21 @@ class Debugger():
|
||||||
cur_col += 1
|
cur_col += 1
|
||||||
ScrolledTextBox(out_text, non_blocking=True)
|
ScrolledTextBox(out_text, non_blocking=True)
|
||||||
|
|
||||||
##### # #
|
##### # #
|
||||||
# # # # #### #### #### ###### # # # ## ##### #### # #
|
# # # # #### #### #### ###### # # # ## ##### #### # #
|
||||||
# # # # # # # # # # # # # # # # # # #
|
# # # # # # # # # # # # # # # # # # #
|
||||||
# ###### # # # # #### ##### # # # # # # # ######
|
# ###### # # # # #### ##### # # # # # # # ######
|
||||||
# # # # # # # # # # # # ###### # # # #
|
# # # # # # # # # # # # ###### # # # #
|
||||||
# # # # # # # # # # # # # # # # # # # # #
|
# # # # # # # # # # # # # # # # # # # # #
|
||||||
##### # # #### #### #### ###### ## ## # # # #### # #
|
##### # # #### #### #### ###### ## ## # # # #### # #
|
||||||
|
|
||||||
# # # #
|
# # # #
|
||||||
# # ## ##### # ## ##### # ###### #### # # # # # #
|
# # ## ##### # ## ##### # ###### #### # # # # # #
|
||||||
# # # # # # # # # # # # # # # # # # ## #
|
# # # # # # # # # # # # # # # # # # ## #
|
||||||
# # # # # # # # # ##### # ##### #### # # # # # # #
|
# # # # # # # # # ##### # ##### #### # # # # # # #
|
||||||
# # ###### ##### # ###### # # # # # # # # # # # #
|
# # ###### ##### # ###### # # # # # # # # # # # #
|
||||||
# # # # # # # # # # # # # # # # # # # # ##
|
# # # # # # # # # # # # # # # # # # # # ##
|
||||||
# # # # # # # # ##### ###### ###### #### ## ## # # #
|
# # # # # # # # ##### ###### ###### #### ## ## # # #
|
||||||
|
|
||||||
def _choose_auto_watches(self, my_locals):
|
def _choose_auto_watches(self, my_locals):
|
||||||
ChangeLookAndFeel(COLOR_SCHEME)
|
ChangeLookAndFeel(COLOR_SCHEME)
|
||||||
|
@ -8215,7 +8257,7 @@ class Debugger():
|
||||||
sorted_dict[key] = my_locals[key]
|
sorted_dict[key] = my_locals[key]
|
||||||
for key in sorted_dict:
|
for key in sorted_dict:
|
||||||
line.append(CB(key, key=key, size=(longest_line, 1),
|
line.append(CB(key, key=key, size=(longest_line, 1),
|
||||||
default=Debugger.local_choices[key] if key in Debugger.local_choices else False))
|
default=self.local_choices[key] if key in self.local_choices else False))
|
||||||
if cur_col + 1 == num_cols:
|
if cur_col + 1 == num_cols:
|
||||||
cur_col = 0
|
cur_col = 0
|
||||||
layout.append(line)
|
layout.append(line)
|
||||||
|
@ -8226,7 +8268,7 @@ class Debugger():
|
||||||
layout.append(line)
|
layout.append(line)
|
||||||
|
|
||||||
layout += [
|
layout += [
|
||||||
[Text('Custom Watch'), Input(default_text=Debugger.custom_watch, size=(60, 1), key='_CUSTOM_WATCH_')]]
|
[Text('Custom Watch (any expression)'), Input(default_text=self.custom_watch, size=(40, 1), key='_CUSTOM_WATCH_')]]
|
||||||
layout += [
|
layout += [
|
||||||
[Ok(), Cancel(), Button('Clear All'), Button('Select [almost] All', key='_AUTO_SELECT_')]]
|
[Ok(), Cancel(), Button('Clear All'), Button('Select [almost] All', key='_AUTO_SELECT_')]]
|
||||||
|
|
||||||
|
@ -8237,12 +8279,12 @@ class Debugger():
|
||||||
if event in (None, 'Cancel'):
|
if event in (None, 'Cancel'):
|
||||||
break
|
break
|
||||||
elif event == 'Ok':
|
elif event == 'Ok':
|
||||||
Debugger.local_choices = values
|
self.local_choices = values
|
||||||
Debugger.custom_watch = values['_CUSTOM_WATCH_']
|
self.custom_watch = values['_CUSTOM_WATCH_']
|
||||||
break
|
break
|
||||||
elif event == 'Clear All':
|
elif event == 'Clear All':
|
||||||
PopupQuickMessage('Cleared Auto Watches', auto_close=True, auto_close_duration=3, non_blocking=True,
|
PopupQuickMessage('Cleared Auto Watches', auto_close=True, auto_close_duration=3, non_blocking=True,
|
||||||
text_color='red', font='ANY 18')
|
text_color='red', font='ANY 18')
|
||||||
for key in sorted_dict:
|
for key in sorted_dict:
|
||||||
window.Element(key).Update(False)
|
window.Element(key).Update(False)
|
||||||
window.Element('_CUSTOM_WATCH_').Update('')
|
window.Element('_CUSTOM_WATCH_').Update('')
|
||||||
|
@ -8271,11 +8313,11 @@ class Debugger():
|
||||||
# # # # # # # # # # # # #
|
# # # # # # # # # # # # #
|
||||||
# # # # # # # # # # # # ## #
|
# # # # # # # # # # # # ## #
|
||||||
# # # # # ## # # # # ## ##
|
# # # # # ## # # # # ## ##
|
||||||
## ## # # # ##### #### # #
|
## ## # # # ##### #### # #
|
||||||
|
|
||||||
def _build_floating_window(self):
|
def _build_floating_window(self, location=(None, None)):
|
||||||
if Debugger.popout_window:
|
if self.popout_window: # if floating window already exists, close it first
|
||||||
Debugger.popout_window.Close()
|
self.popout_window.Close()
|
||||||
ChangeLookAndFeel('Topanga')
|
ChangeLookAndFeel('Topanga')
|
||||||
num_cols = 2
|
num_cols = 2
|
||||||
width_var = 15
|
width_var = 15
|
||||||
|
@ -8283,19 +8325,19 @@ class Debugger():
|
||||||
layout = []
|
layout = []
|
||||||
line = []
|
line = []
|
||||||
col = 0
|
col = 0
|
||||||
Debugger.popout_choices = Debugger.local_choices if Debugger.local_choices != {} else {}
|
self.popout_choices = self.local_choices
|
||||||
if Debugger.popout_choices == {}:
|
if self.popout_choices == {}: # if nothing chosen, then choose all non-_ variables
|
||||||
for key in sorted(Debugger.locals.keys()):
|
for key in sorted(self.locals.keys()):
|
||||||
if not key.startswith('_'):
|
self.popout_choices[key] = not key.startswith('_')
|
||||||
Debugger.popout_choices[key] = True
|
|
||||||
|
|
||||||
width_var = max([len(key) for key in Debugger.popout_choices])
|
width_var = max([len(key) for key in self.popout_choices])
|
||||||
for key in Debugger.popout_choices:
|
for key in self.popout_choices:
|
||||||
if Debugger.popout_choices[key] is True:
|
if self.popout_choices[key] is True:
|
||||||
value = str(Debugger.locals.get(key))
|
value = str(self.locals.get(key))
|
||||||
line += [Text(key, size=(width_var, 1), font='Sans 8'), Text(' = ', font='Sans 8'),
|
h = min(len(value)//width_value + 1, MAX_LINES_PER_RESULT_FLOATING)
|
||||||
Text(value, key=key, size=(width_value, 1 if len(value) < width_value else 2),
|
line += [Text(f'{key}', size=(width_var, 1), font=POPOUT_WINDOW_FONT),
|
||||||
font='Sans 8')]
|
Text(' = ', font=POPOUT_WINDOW_FONT),
|
||||||
|
Text(value, key=key, size=(width_value, h), font=POPOUT_WINDOW_FONT)]
|
||||||
if col + 1 < num_cols:
|
if col + 1 < num_cols:
|
||||||
line += [VerticalSeparator(), T(' ')]
|
line += [VerticalSeparator(), T(' ')]
|
||||||
col += 1
|
col += 1
|
||||||
|
@ -8308,13 +8350,16 @@ class Debugger():
|
||||||
layout = [[Column(layout), Column(
|
layout = [[Column(layout), Column(
|
||||||
[[Button('', key='_EXIT_', image_data=red_x, button_color=('#282923', '#282923'), border_width=0)]])]]
|
[[Button('', key='_EXIT_', image_data=red_x, button_color=('#282923', '#282923'), border_width=0)]])]]
|
||||||
|
|
||||||
Debugger.popout_window = Window('Floating', layout, alpha_channel=0, no_titlebar=True, grab_anywhere=True,
|
self.popout_window = Window('Floating', layout, alpha_channel=0, no_titlebar=True, grab_anywhere=True,
|
||||||
element_padding=(0, 0), margins=(0, 0), keep_on_top=True, ).Finalize()
|
element_padding=(0, 0), margins=(0, 0), keep_on_top=True,
|
||||||
screen_size = Debugger.popout_window.GetScreenDimensions()
|
right_click_menu=['&Right', ['Debugger::RightClick', 'Exit::RightClick']], location=location ).Finalize()
|
||||||
Debugger.popout_window.Move(screen_size[0] - Debugger.popout_window.Size[0], 0)
|
if location == (None, None):
|
||||||
Debugger.popout_window.SetAlpha(1)
|
screen_size = self.popout_window.GetScreenDimensions()
|
||||||
|
self.popout_window.Move(screen_size[0] - self.popout_window.Size[0], 0)
|
||||||
|
self.popout_window.SetAlpha(1)
|
||||||
|
|
||||||
ChangeLookAndFeel('SystemDefault')
|
ChangeLookAndFeel('SystemDefault')
|
||||||
|
return True
|
||||||
|
|
||||||
######
|
######
|
||||||
# # ###### ###### ##### ###### #### # #
|
# # ###### ###### ##### ###### #### # #
|
||||||
|
@ -8338,18 +8383,21 @@ class Debugger():
|
||||||
# # # # # # # # # # # # #
|
# # # # # # # # # # # # #
|
||||||
# # # # # # # # # # # # ## #
|
# # # # # # # # # # # # ## #
|
||||||
# # # # # ## # # # # ## ##
|
# # # # # ## # # # # ## ##
|
||||||
## ## # # # ##### #### # #
|
## ## # # # ##### #### # #
|
||||||
|
|
||||||
def _refresh_floating_window():
|
def _refresh_floating_window(self):
|
||||||
if not Debugger.popout_window:
|
if not self.popout_window:
|
||||||
return
|
return
|
||||||
for key in Debugger.popout_choices:
|
for key in self.popout_choices:
|
||||||
if Debugger.popout_choices[key] is True:
|
if self.popout_choices[key] is True and key in self.locals:
|
||||||
Debugger.popout_window.Element(key).Update(Debugger.locals.get(key))
|
if key is not None:
|
||||||
event, values = Debugger.popout_window.Read(timeout=1)
|
self.popout_window.Element(key, silent_on_error=True).Update(self.locals.get(key))
|
||||||
if event in (None, '_EXIT_'):
|
event, values = self.popout_window.Read(timeout=1)
|
||||||
Debugger.popout_window.Close()
|
if event in (None, '_EXIT_', 'Exit::RightClick'):
|
||||||
Debugger.popout_window = None
|
self.popout_window.Close()
|
||||||
|
self.popout_window = None
|
||||||
|
elif event == 'Debugger::RightClick':
|
||||||
|
show_debugger_window()
|
||||||
|
|
||||||
|
|
||||||
# 888 888 .d8888b. d8888 888 888 888 888
|
# 888 888 .d8888b. d8888 888 888 888 888
|
||||||
|
@ -8371,123 +8419,68 @@ class Debugger():
|
||||||
# 888 "Y88888 888 888 "Y8888P "Y888 888 "Y88P" 888 888 88888P'
|
# 888 "Y88888 888 888 "Y8888P "Y888 888 "Y88P" 888 888 88888P'
|
||||||
|
|
||||||
|
|
||||||
# The *args are needed because sometimes this is called by tkinter and it sends in some parms of something
|
|
||||||
# Due to the BIND that happens to the key
|
|
||||||
''
|
|
||||||
|
|
||||||
|
|
||||||
def show_debugger_window(*args):
|
def show_debugger_window(location=(None, None), *args):
|
||||||
|
if Debugger.debugger is None:
|
||||||
|
Debugger.debugger = Debugger()
|
||||||
|
debugger = Debugger.debugger
|
||||||
frame = inspect.currentframe()
|
frame = inspect.currentframe()
|
||||||
prev_frame = inspect.currentframe().f_back
|
prev_frame = inspect.currentframe().f_back
|
||||||
# frame, *others = inspect.stack()[1]
|
# frame, *others = inspect.stack()[1]
|
||||||
try:
|
try:
|
||||||
Debugger.locals = frame.f_back.f_locals
|
debugger.locals = frame.f_back.f_locals
|
||||||
Debugger.globals = frame.f_back.f_globals
|
debugger.globals = frame.f_back.f_globals
|
||||||
finally:
|
finally:
|
||||||
del frame
|
del frame
|
||||||
|
|
||||||
if not Debugger.watcher_window:
|
if not debugger.watcher_window:
|
||||||
Debugger.watcher_window = debugger._build_main_debugger_window()
|
debugger.watcher_window = debugger._build_main_debugger_window(location=location)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
#
|
def show_debugger_popout_window(location=(None, None), *args):
|
||||||
#
|
if Debugger.debugger is None:
|
||||||
# def show_debugger_window(*args):
|
Debugger.debugger = Debugger()
|
||||||
# frame, *others = inspect.stack()[1]
|
debugger = Debugger.debugger
|
||||||
# try:
|
|
||||||
# Debugger.locals = frame.f_back.f_locals
|
|
||||||
# Debugger.globals = frame.f_back.f_globals
|
|
||||||
# finally:
|
|
||||||
# del frame
|
|
||||||
#
|
|
||||||
# if not Debugger.watcher_window:
|
|
||||||
# Debugger.watcher_window = debugger._build_main_debugger_window()
|
|
||||||
# return True
|
|
||||||
#
|
|
||||||
|
|
||||||
def show_debugger_popout_window(*args):
|
|
||||||
frame = inspect.currentframe()
|
frame = inspect.currentframe()
|
||||||
prev_frame = inspect.currentframe().f_back
|
prev_frame = inspect.currentframe().f_back
|
||||||
# frame = inspect.getframeinfo(prev_frame)
|
# frame = inspect.getframeinfo(prev_frame)
|
||||||
# frame, *others = inspect.stack()[1]
|
# frame, *others = inspect.stack()[1]
|
||||||
try:
|
try:
|
||||||
Debugger.locals = frame.f_back.f_locals
|
debugger.locals = frame.f_back.f_locals
|
||||||
Debugger.globals = frame.f_back.f_globals
|
debugger.globals = frame.f_back.f_globals
|
||||||
finally:
|
finally:
|
||||||
del frame
|
del frame
|
||||||
if Debugger.popout_window:
|
if debugger.popout_window:
|
||||||
return
|
debugger.popout_window.Close()
|
||||||
debugger._build_floating_window()
|
debugger.popout_window = None
|
||||||
|
debugger._build_floating_window(location=location)
|
||||||
|
|
||||||
#
|
|
||||||
# def show_debugger_popout_window(*args):
|
|
||||||
#
|
|
||||||
# frame = inspect.currentframe()
|
|
||||||
# prev_frame = inspect.currentframe().f_back
|
|
||||||
# frame = inspect.getframeinfo(prev_frame)
|
|
||||||
# # frame, *others = inspect.stack()[1]
|
|
||||||
# try:
|
|
||||||
# Debugger.locals = frame.f_back.f_locals
|
|
||||||
# Debugger.globals = frame.f_back.f_globals
|
|
||||||
# finally:
|
|
||||||
# del frame
|
|
||||||
# if Debugger.popout_window:
|
|
||||||
# return
|
|
||||||
# if not Debugger.popout_window:
|
|
||||||
# Debugger.popout_window = debugger._build_floating_window()
|
|
||||||
|
|
||||||
|
|
||||||
def refresh_debugger():
|
def refresh_debugger():
|
||||||
|
if Debugger.debugger is None:
|
||||||
|
Debugger.debugger = Debugger()
|
||||||
|
debugger = Debugger.debugger
|
||||||
Window.read_call_from_debugger = True
|
Window.read_call_from_debugger = True
|
||||||
frame = inspect.currentframe()
|
frame = inspect.currentframe()
|
||||||
frame = inspect.currentframe().f_back
|
frame = inspect.currentframe().f_back
|
||||||
# frame, *others = inspect.stack()[1]
|
# frame, *others = inspect.stack()[1]
|
||||||
try:
|
try:
|
||||||
Debugger.locals = frame.f_back.f_locals
|
debugger.locals = frame.f_back.f_locals
|
||||||
Debugger.globals = frame.f_back.f_globals
|
debugger.globals = frame.f_back.f_globals
|
||||||
finally:
|
finally:
|
||||||
del frame
|
del frame
|
||||||
Debugger._refresh_floating_window() if Debugger.popout_window else None
|
debugger._refresh_floating_window() if debugger.popout_window else None
|
||||||
rc = debugger._refresh_main_debugger_window(Debugger.locals, Debugger.globals) if Debugger.watcher_window else False
|
rc = debugger._refresh_main_debugger_window(debugger.locals, debugger.globals) if debugger.watcher_window else False
|
||||||
Window.read_call_from_debugger = False
|
Window.read_call_from_debugger = False
|
||||||
return rc
|
return rc
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# def refresh_debugger():
|
|
||||||
# Window.read_call_from_debugger = True
|
|
||||||
# frame = inspect.currentframe()
|
|
||||||
# prev_frame = inspect.currentframe().f_back
|
|
||||||
# # frame, *others = inspect.stack()[1]
|
|
||||||
# try:
|
|
||||||
# Debugger.locals = frame.f_back.f_locals
|
|
||||||
# Debugger.globals = frame.f_back.f_globals
|
|
||||||
# finally:
|
|
||||||
# del frame
|
|
||||||
# Debugger._refresh_floating_window() if Debugger.popout_window else None
|
|
||||||
# rc = debugger._refresh_main_debugger_window(Debugger.locals, Debugger.globals) if Debugger.watcher_window else False
|
|
||||||
# Window.read_call_from_debugger = False
|
|
||||||
# return rc
|
|
||||||
|
|
||||||
|
|
||||||
def fullname(o):
|
|
||||||
# o.__module__ + "." + o.__class__.__qualname__ is an example in
|
|
||||||
# this context of H.L. Mencken's "neat, plausible, and wrong."
|
|
||||||
# Python makes no guarantees as to whether the __module__ special
|
|
||||||
# attribute is defined, so we take a more circumspect approach.
|
|
||||||
# Alas, the module name is explicitly excluded from __qualname__
|
|
||||||
# in Python 3.
|
|
||||||
|
|
||||||
module = o.__class__.__module__
|
|
||||||
if module is None or module == str.__class__.__module__:
|
|
||||||
return o.__class__.__name__ # Avoid reporting __builtin__
|
|
||||||
else:
|
|
||||||
return module + '.' + o.__class__.__name__
|
|
||||||
|
|
||||||
|
|
||||||
debugger = Debugger()
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
d8b
|
d8b
|
||||||
|
|
Loading…
Reference in New Issue