mirror of
https://github.com/python/cpython.git
synced 2025-08-21 17:25:34 +00:00
Issue #1342811: Fix leak in Tkinter.Menu.delete. Commands associated to
menu entries were not deleted. Backport from trunk r65622.
This commit is contained in:
parent
7641b1c943
commit
78813dccd8
2 changed files with 13 additions and 0 deletions
|
@ -2669,7 +2669,17 @@ class Menu(Widget):
|
|||
self.insert(index, 'separator', cnf or kw)
|
||||
def delete(self, index1, index2=None):
|
||||
"""Delete menu items between INDEX1 and INDEX2 (not included)."""
|
||||
if index2 is None:
|
||||
index2 = index1
|
||||
cmds = []
|
||||
for i in range(self.index(index1), self.index(index2)+1):
|
||||
if 'command' in self.entryconfig(i):
|
||||
c = str(self.entrycget(i, 'command'))
|
||||
if c in self._tclCommands:
|
||||
cmds.append(c)
|
||||
self.tk.call(self._w, 'delete', index1, index2)
|
||||
for c in cmds:
|
||||
self.deletecommand(c)
|
||||
def entrycget(self, index, option):
|
||||
"""Return the resource value of an menu item for OPTION at INDEX."""
|
||||
return self.tk.call(self._w, 'entrycget', index, '-' + option)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue