MCPcopy Index your code
hub / github.com/python/cpython / StackViewer

Class StackViewer

Lib/idlelib/debugger.py:424–505  ·  view source on GitHub ↗

Code stack viewer for debugger GUI.

Source from the content-addressed store, hash-verified

422
423
424class StackViewer(ScrolledList):
425 "Code stack viewer for debugger GUI."
426
427 def __init__(self, master, flist, gui):
428 if macosx.isAquaTk():
429 # At least on with the stock AquaTk version on OSX 10.4 you'll
430 # get a shaking GUI that eventually kills IDLE if the width
431 # argument is specified.
432 ScrolledList.__init__(self, master)
433 else:
434 ScrolledList.__init__(self, master, width=80)
435 self.flist = flist
436 self.gui = gui
437 self.stack = []
438
439 def load_stack(self, stack, index=None):
440 self.stack = stack
441 self.clear()
442 for i in range(len(stack)):
443 frame, lineno = stack[i]
444 try:
445 modname = frame.f_globals["__name__"]
446 except:
447 modname = "?"
448 code = frame.f_code
449 filename = code.co_filename
450 funcname = code.co_name
451 import linecache
452 sourceline = linecache.getline(filename, lineno)
453 sourceline = sourceline.strip()
454 if funcname in ("?", "", None):
455 item = "%s, line %d: %s" % (modname, lineno, sourceline)
456 else:
457 item = "%s.%s(), line %d: %s" % (modname, funcname,
458 lineno, sourceline)
459 if i == index:
460 item = "> " + item
461 self.append(item)
462 if index is not None:
463 self.select(index)
464
465 def popup_event(self, event):
466 "Override base method."
467 if self.stack:
468 return ScrolledList.popup_event(self, event)
469
470 def fill_menu(self):
471 "Override base method."
472 menu = self.menu
473 menu.add_command(label="Go to source line",
474 command=self.goto_source_line)
475 menu.add_command(label="Show stack frame",
476 command=self.show_stack_frame)
477
478 def on_select(self, index):
479 "Override base method."
480 if 0 <= index < len(self.stack):
481 self.gui.show_frame(self.stack[index])

Callers 1

show_stackMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…