]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
backport loewis' checkin of
authorMichael W. Hudson <mwh@python.net>
Fri, 23 Aug 2002 15:27:52 +0000 (15:27 +0000)
committerMichael W. Hudson <mwh@python.net>
Fri, 23 Aug 2002 15:27:52 +0000 (15:27 +0000)
    revision 1.161 of Tkinter.py

Ignore widgets with unknown names in winfo_children. Fixes #518283.
2.2.2 candidate.

Lib/lib-tk/Tkinter.py

index 9b400aa857d9c75e32a316aee36ab7cada356633..9f2b2e00648e99845085b58d41552d85b650e922 100644 (file)
@@ -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)