]> granicus.if.org Git - python/commitdiff
Ignore widgets with unknown names in winfo_children. Fixes #518283.
authorMartin v. Löwis <martin@v.loewis.de>
Wed, 27 Mar 2002 17:15:57 +0000 (17:15 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Wed, 27 Mar 2002 17:15:57 +0000 (17:15 +0000)
2.2.2 candidate.

Lib/lib-tk/Tkinter.py

index 65d81874a371d9edeb511c1aaa803cfeb58b6064..f35cbd8ae5311b3a1bc9adef3479dc2b3c00bbd4 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)