def cleanup(): from Tkinter import _default_root, TclError import Tkinter try: if _default_root: _default_root.destroy() except TclError: pass Tkinter._default_root = None
def cleanup(): try: from Tkinter import _default_root, TclError # requires 2to3 import Tkinter as TKNTR try: if _default_root: _default_root.destroy() except TclError: pass TKNTR._default_root = None except SystemError: # If cleanup() is called before pyraf fully loads, we will # see: "SystemError: Parent module 'pyraf' not loaded". In that case, # since nothing was done yet w/ _default_root, we can safely skip this. pass