From: Martin v. Löwis Date: Sat, 2 Aug 2008 07:21:06 +0000 (+0000) Subject: Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap X-Git-Tag: v2.5.3c1~74 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c7af7f36a664f4f413d4b6bb0558632efeaa7824;p=python Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap Tcl command objects. Backport of r65399. --- diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py index 0ae81e0f2d..6f00397650 100644 --- a/Lib/lib-tk/Tkinter.py +++ b/Lib/lib-tk/Tkinter.py @@ -1072,18 +1072,18 @@ class Misc: def nametowidget(self, name): """Return the Tkinter instance of a widget identified by its Tcl name NAME.""" + name = str(name).split('.') w = self - if name[0] == '.': + + if not name[0]: w = w._root() name = name[1:] - while name: - i = name.find('.') - if i >= 0: - name, tail = name[:i], name[i+1:] - else: - tail = '' - w = w.children[name] - name = tail + + for n in name: + if not n: + break + w = w.children[n] + return w _nametowidget = nametowidget def _register(self, func, subst=None, needcleanup=1): diff --git a/Misc/NEWS b/Misc/NEWS index 153e551fed..c74072e868 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -74,6 +74,8 @@ Core and builtins Library ------- +- Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap Tcl command objects. + - Issue #3339: dummy_thread.acquire() could return None which is not a valid return value.