Index: Lib/lib-tk/Tkinter.py =================================================================== --- Lib/lib-tk/Tkinter.py (revision 70642) +++ Lib/lib-tk/Tkinter.py (working copy) @@ -340,6 +340,7 @@ # XXX font command? _tclCommands = None + _scheduledCommands = None def destroy(self): """Internal function. @@ -495,10 +496,14 @@ func(*args) finally: try: - self.deletecommand(name) + if self._scheduledCommands is not None: + self._scheduledCommands.remove(name) + self.tk.deletecommand(name) except TclError: pass - name = self._register(callit) + name = self._register(callit, needcleanup=False) + if self._scheduledCommands is not None: + self._scheduledCommands.append(name) return self.tk.call('after', ms, name) def after_idle(self, func, *args): """Call FUNC once if the Tcl main loop has no event to @@ -517,7 +522,9 @@ # In Tk 8.3, splitlist returns: (script, type) # In Tk 8.4, splitlist may return (script, type) or (script,) script = self.tk.splitlist(data)[0] - self.deletecommand(script) + if self._scheduledCommands is not None: + self._scheduledCommands.remove(script) + self.tk.deletecommand(script) except TclError: pass self.tk.call('after', 'cancel', id) @@ -1640,6 +1647,7 @@ if ext not in ('.py', '.pyc', '.pyo'): baseName = baseName + ext interactive = 0 + self._scheduledCommands = [] self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) if useTk: self._loadtk()