]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
added getitem/setitem to Image class; changed call wrapping (again)
authorGuido van Rossum <guido@python.org>
Mon, 18 Sep 1995 21:54:35 +0000 (21:54 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 18 Sep 1995 21:54:35 +0000 (21:54 +0000)
Lib/lib-tk/Tkinter.py
Lib/tkinter/Tkinter.py

index abe8f823590ccee9bb189942703561c813f92356..3b52ae11827096c6cf17de568fe6651593e84ace 100644 (file)
@@ -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))
index abe8f823590ccee9bb189942703561c813f92356..3b52ae11827096c6cf17de568fe6651593e84ace 100755 (executable)
@@ -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))