From 76f587b7f8d10372f0efc4be94239f3d73c92421 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 21 Jan 1997 23:22:03 +0000 Subject: Avoid traceback in selection_own_get() when no Tk widget owns the selection; return None instead. --- Lib/lib-tk/Tkinter.py | 7 ++++--- Lib/tkinter/Tkinter.py | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py index 9fb1d02..a19cf50 100644 --- a/Lib/lib-tk/Tkinter.py +++ b/Lib/lib-tk/Tkinter.py @@ -267,9 +267,10 @@ class Misc: def selection_own_get(self, **kw): "Find owner of X selection." if not kw.has_key('displayof'): kw['displayof'] = self._w - return self._nametowidget( - apply(self.tk.call, - ('selection', 'own') + self._options(kw))) + name = apply(self.tk.call, + ('selection', 'own') + self._options(kw)) + if not name: return None + return self._nametowidget(name) def send(self, interp, cmd, *args): return apply(self.tk.call, ('send', interp, cmd) + args) def lower(self, belowThis=None): diff --git a/Lib/tkinter/Tkinter.py b/Lib/tkinter/Tkinter.py index 9fb1d02..a19cf50 100755 --- a/Lib/tkinter/Tkinter.py +++ b/Lib/tkinter/Tkinter.py @@ -267,9 +267,10 @@ class Misc: def selection_own_get(self, **kw): "Find owner of X selection." if not kw.has_key('displayof'): kw['displayof'] = self._w - return self._nametowidget( - apply(self.tk.call, - ('selection', 'own') + self._options(kw))) + name = apply(self.tk.call, + ('selection', 'own') + self._options(kw)) + if not name: return None + return self._nametowidget(name) def send(self, interp, cmd, *args): return apply(self.tk.call, ('send', interp, cmd) + args) def lower(self, belowThis=None): -- cgit v0.12