8000 Feature: Add search heap viewer by object ID functionality Issue #3591 by qwopp · Pull Request #3603 · thonny/thonny · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Feature: Add search heap viewer by object ID functionality Issue #3591 #3603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions thonny/plugins/heap.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,20 @@ def __init__(self, master):
self.tree.heading("id", text=tr("ID"), anchor=tk.W)
self.tree.heading("value", text=tr("Value"), anchor=tk.W)

get_workbench().bind("get_heap_response", self._handle_heap_event, True)
self.search_var = tk.StringVar()
self.search_frame = ttk.Frame(self)
self.search_frame.grid(row=2, column=0, sticky="ew", columnspan=2)
self.search_label = ttk.Label(self.search_frame, text=tr("Search ID:"))
self.search_label.pack(side="left", padx=(5, 2))
self.search_entry = ttk.Entry(self.search_frame, textvariable=self.search_var)
self.search_entry.pack(side="left", fill="x", expand=True, padx=(0, 5))
self.search_entry.bind("<Return>", lambda event: self._search_heap())
self.search_button = ttk.Button(self.search_frame, text=tr("Find"), command=self._search_heap)
self.search_button.pack(side="left")

get_workbench().bind("get_heap_response", self._handle_heap_event, True)
get_workbench().bind("DebuggerResponse", self._request_heap_data, True)
get_workbench().bind("ToplevelResponse", self._request_heap_data, True)
# Showing new globals may introduce new interesting objects
get_workbench().bind("get_globals_response", self._request_heap_data, True)

self.bind("<Map>", self._on_map, True)
Expand All @@ -41,6 +50,18 @@ def __init__(self, master):
padding=(3, 0),
)

def _search_heap(self):
search_id = self.search_var.get()
found = False
for child in self.tree.get_children():
if self.tree.set(child, "id").startswith(search_id):
self.tree.selection_set(child)
self.tree.see(child)
found = True
break
if not found:
tk.messagebox.showinfo(tr("Search"), tr(f"No ID starting with '{search_id}' found in the heap."))

def _update_data(self, data):
self._clear_tree()
for value_id in sorted(data.keys()):
Expand Down
0