From 44b88b8dd1af98583208071d6b46c130d74b501f Mon Sep 17 00:00:00 2001 From: "Nicholas H.Tollervey" Date: Mon, 20 Dec 2021 16:59:30 +0000 Subject: [PATCH] Initial work. --- mu/interface/main.py | 13 ++++++++----- mu/modes/debugger.py | 5 ++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/mu/interface/main.py b/mu/interface/main.py index dd2815a33..e57f469b2 100644 --- a/mu/interface/main.py +++ b/mu/interface/main.py @@ -819,18 +819,21 @@ def add_debug_inspector(self): for col, width in enumerate(self.debug_widths): self.debug_inspector.setColumnWidth(col, width) - def update_debug_inspector(self, locals_dict): + def update_debug_inspector(self, locals_dict, globals_dict): """ - Given the contents of a dict representation of the locals in the - current stack frame, update the debug inspector with the new values. + Given the contents of a dict representation of the locals and + globals in the current stack frame, update the debug inspector with the + new values. """ excluded_names = ["__builtins__", "__debug_code__", "__debug_script__"] - names = sorted([x for x in locals_dict if x not in excluded_names]) + locals_names = sorted([x for x in locals_dict if x not in excluded_names]) + globals_names = sorted([x for x in globals_dict if x not in excluded_names]) # Remove rows so we keep the same column layouts if manually set while self.debug_model.rowCount() > 0: self.debug_model.removeRow(0) - for name in names: + # Add globals to the top. + for name in locals_names: item_to_expand = None try: # DANGER! diff --git a/mu/modes/debugger.py b/mu/modes/debugger.py index f4465debe..375bf901c 100644 --- a/mu/modes/debugger.py +++ b/mu/modes/debugger.py @@ -332,10 +332,13 @@ def debug_on_stack(self, stack): """ if stack: locals_dict = {} + globals_dict = {} for frame in stack: for k, v in frame[1]["locals"].items(): locals_dict[k] = v - self.view.update_debug_inspector(locals_dict) + for k, v in frame[1]["globals"].items(): + globals_dict[k] = v + self.view.update_debug_inspector(locals_dict, globals_dict) def debug_on_postmortem(self, args, kwargs): """