summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2002-03-27 17:15:57 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2002-03-27 17:15:57 (GMT)
commitf2041b8aa6a451f8602dc5ee4cd4db838d467519 (patch)
treedc010da96e1e7a9b4b13122b977a687666738245 /Lib
parent38a8916134adaa0222c0e8d904c2b2b840cfb79b (diff)
downloadcpython-f2041b8aa6a451f8602dc5ee4cd4db838d467519.zip
cpython-f2041b8aa6a451f8602dc5ee4cd4db838d467519.tar.gz
cpython-f2041b8aa6a451f8602dc5ee4cd4db838d467519.tar.bz2
Ignore widgets with unknown names in winfo_children. Fixes #518283.
2.2.2 candidate.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/lib-tk/Tkinter.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py
index 65d8187..f35cbd8 100644
--- a/Lib/lib-tk/Tkinter.py
+++ b/Lib/lib-tk/Tkinter.py
@@ -605,9 +605,17 @@ class Misc:
self.tk.call('winfo', 'cells', self._w))
def winfo_children(self):
"""Return a list of all widgets which are children of this widget."""
- return map(self._nametowidget,
- self.tk.splitlist(self.tk.call(
- 'winfo', 'children', self._w)))
+ result = []
+ for child in self.tk.splitlist(
+ self.tk.call('winfo', 'children', self._w)):
+ try:
+ # Tcl sometimes returns extra windows, e.g. for
+ # menus; those need to be skipped
+ result.append(self._nametowidget(child))
+ except KeyError:
+ pass
+ return result
+
def winfo_class(self):
"""Return window class name of this widget."""
return self.tk.call('winfo', 'class', self._w)