From: Guido van Rossum Date: Mon, 18 Sep 1995 21:54:35 +0000 (+0000) Subject: added getitem/setitem to Image class; changed call wrapping (again) X-Git-Tag: v1.3~111 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=71b1a90bad57e547085fde4f6e4a6d562b11467a;p=thirdparty%2FPython%2Fcpython.git added getitem/setitem to Image class; changed call wrapping (again) --- diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py index abe8f823590c..3b52ae118270 100644 --- a/Lib/lib-tk/Tkinter.py +++ b/Lib/lib-tk/Tkinter.py @@ -425,7 +425,7 @@ class Misc: name = tail return w def _register(self, func, subst=None): - f = CallWrapper(func, subst, self).__call__ + f = self._wrap(func, subst) name = `id(f)` if hasattr(func, 'im_func'): func = func.im_func @@ -474,6 +474,8 @@ class Misc: exc, val, tb = sys.exc_type, sys.exc_value, sys.exc_traceback root = self._root() root.report_callback_exception(exc, val, tb) + def _wrap(self, func, subst=None): + return CallWrapper(func, subst, self).__call__ class CallWrapper: def __init__(self, func, subst, widget): @@ -1269,6 +1271,10 @@ class Image: def __del__(self): if self.name: self.tk.call('image', 'delete', self.name) + def __setitem__(self, key, value): + self.tk.call(self.name, 'configure', '-'+key, value) + def __getitem__(self, key): + return self.tk.call(self.name, 'configure', '-'+key) def height(self): return self.tk.getint( self.tk.call('image', 'height', self.name)) diff --git a/Lib/tkinter/Tkinter.py b/Lib/tkinter/Tkinter.py index abe8f823590c..3b52ae118270 100755 --- a/Lib/tkinter/Tkinter.py +++ b/Lib/tkinter/Tkinter.py @@ -425,7 +425,7 @@ class Misc: name = tail return w def _register(self, func, subst=None): - f = CallWrapper(func, subst, self).__call__ + f = self._wrap(func, subst) name = `id(f)` if hasattr(func, 'im_func'): func = func.im_func @@ -474,6 +474,8 @@ class Misc: exc, val, tb = sys.exc_type, sys.exc_value, sys.exc_traceback root = self._root() root.report_callback_exception(exc, val, tb) + def _wrap(self, func, subst=None): + return CallWrapper(func, subst, self).__call__ class CallWrapper: def __init__(self, func, subst, widget): @@ -1269,6 +1271,10 @@ class Image: def __del__(self): if self.name: self.tk.call('image', 'delete', self.name) + def __setitem__(self, key, value): + self.tk.call(self.name, 'configure', '-'+key, value) + def __getitem__(self, key): + return self.tk.call(self.name, 'configure', '-'+key) def height(self): return self.tk.getint( self.tk.call('image', 'height', self.name))