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

Class NamespaceViewer

Lib/idlelib/debugger.py:508–595  ·  view source on GitHub ↗

Global/local namespace viewer for debugger GUI.

Source from the content-addressed store, hash-verified

506
507
508class NamespaceViewer:
509 "Global/local namespace viewer for debugger GUI."
510
511 def __init__(self, master, title, odict=None): # XXX odict never passed.
512 width = 0
513 height = 40
514 if odict:
515 height = 20*len(odict) # XXX 20 == observed height of Entry widget
516 self.master = master
517 self.title = title
518 import reprlib
519 self.repr = reprlib.Repr()
520 self.repr.maxstring = 60
521 self.repr.maxother = 60
522 self.frame = frame = Frame(master)
523 self.frame.pack(expand=1, fill="both")
524 self.label = Label(frame, text=title, borderwidth=2, relief="groove")
525 self.label.pack(fill="x")
526 self.vbar = vbar = Scrollbar(frame, name="vbar")
527 vbar.pack(side="right", fill="y")
528 self.canvas = canvas = Canvas(frame,
529 height=min(300, max(40, height)),
530 scrollregion=(0, 0, width, height))
531 canvas.pack(side="left", fill="both", expand=1)
532 vbar["command"] = canvas.yview
533 canvas["yscrollcommand"] = vbar.set
534 self.subframe = subframe = Frame(canvas)
535 self.sfid = canvas.create_window(0, 0, window=subframe, anchor="nw")
536 self.load_dict(odict)
537
538 prev_odict = -1 # Needed for initial comparison below.
539
540 def load_dict(self, odict, force=0, rpc_client=None):
541 if odict is self.prev_odict and not force:
542 return
543 subframe = self.subframe
544 frame = self.frame
545 for c in list(subframe.children.values()):
546 c.destroy()
547 self.prev_odict = None
548 if not odict:
549 l = Label(subframe, text="None")
550 l.grid(row=0, column=0)
551 else:
552 #names = sorted(dict)
553 #
554 # Because of (temporary) limitations on the dict_keys type (not yet
555 # public or pickleable), have the subprocess to send a list of
556 # keys, not a dict_keys object. sorted() will take a dict_keys
557 # (no subprocess) or a list.
558 #
559 # There is also an obscure bug in sorted(dict) where the
560 # interpreter gets into a loop requesting non-existing dict[0],
561 # dict[1], dict[2], etc from the debugger_r.DictProxy.
562 # TODO recheck above; see debugger_r 159ff, debugobj 60.
563 keys_list = odict.keys()
564 names = sorted(keys_list)
565

Callers 2

show_localsMethod · 0.85
show_globalsMethod · 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…