summaryrefslogtreecommitdiffstats
path: root/Tools/idle
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-06-25 16:03:19 (GMT)
committerGuido van Rossum <guido@python.org>1999-06-25 16:03:19 (GMT)
commit374c0dfb10ec9bebffbcc9ec30b37043fd13d6dc (patch)
tree791590591bda0ec623aef952c7fd7ab9f615dc6b /Tools/idle
parente689f0087ed3db8a5102ac4afdf147b50cd971e0 (diff)
downloadcpython-374c0dfb10ec9bebffbcc9ec30b37043fd13d6dc.zip
cpython-374c0dfb10ec9bebffbcc9ec30b37043fd13d6dc.tar.gz
cpython-374c0dfb10ec9bebffbcc9ec30b37043fd13d6dc.tar.bz2
Add unregister() method.
Unregister everything at closing. Don't call close() in __del__, rely on explicit call to close().
Diffstat (limited to 'Tools/idle')
-rw-r--r--Tools/idle/WidgetRedirector.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/Tools/idle/WidgetRedirector.py b/Tools/idle/WidgetRedirector.py
index b11b0e4..b49ccf1 100644
--- a/Tools/idle/WidgetRedirector.py
+++ b/Tools/idle/WidgetRedirector.py
@@ -18,11 +18,9 @@ class WidgetRedirector:
return "WidgetRedirector(%s<%s>)" % (self.widget.__class__.__name__,
self.widget._w)
- def __del__(self):
- self.close()
-
def close(self):
- self.dict = {}
+ for name in self.dict.keys():
+ self.unregister(name)
widget = self.widget; del self.widget
orig = self.orig; del self.orig
tk = widget.tk
@@ -39,6 +37,16 @@ class WidgetRedirector:
setattr(self.widget, name, function)
return previous
+ def unregister(self, name):
+ if self.dict.has_key(name):
+ function = self.dict[name]
+ del self.dict[name]
+ if hasattr(self.widget, name):
+ delattr(self.widget, name)
+ return function
+ else:
+ return None
+
def dispatch(self, cmd, *args):
m = self.dict.get(cmd)
try: