(self, odict, force=0, rpc_client=None)
| 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 | |
| 566 | row = 0 |
| 567 | for name in names: |
| 568 | value = odict[name] |
| 569 | svalue = self.repr.repr(value) # repr(value) |
| 570 | # Strip extra quotes caused by calling repr on the (already) |
| 571 | # repr'd value sent across the RPC interface: |
| 572 | if rpc_client: |
| 573 | svalue = svalue[1:-1] |
| 574 | l = Label(subframe, text=name) |
| 575 | l.grid(row=row, column=0, sticky="nw") |
| 576 | l = Entry(subframe, width=0, borderwidth=0) |
| 577 | l.insert(0, svalue) |
| 578 | l.grid(row=row, column=1, sticky="nw") |
| 579 | row = row+1 |
| 580 | self.prev_odict = odict |
| 581 | # XXX Could we use a <Configure> callback for the following? |
| 582 | subframe.update_idletasks() # Alas! |
| 583 | width = subframe.winfo_reqwidth() |
| 584 | height = subframe.winfo_reqheight() |
| 585 | canvas = self.canvas |
| 586 | self.canvas["scrollregion"] = (0, 0, width, height) |
| 587 | if height > 300: |
| 588 | canvas["height"] = 300 |
| 589 | frame.pack(expand=1) |
| 590 | else: |
| 591 | canvas["height"] = height |
| 592 | frame.pack(expand=0) |
| 593 | |
| 594 | def close(self): |
| 595 | self.frame.destroy() |
no test coverage detected