def _init_toolkit():

    def import_toolkit(tk):
        try:
            # Try and import the toolkit's pyface backend init module.
            be = 'pyface.ui.%s.' % tk
            __import__(be + 'init')
        except:
            raise
        return be

    # Get the toolkit.
    if ETSConfig.toolkit:
        be = import_toolkit(ETSConfig.toolkit)
    else:
        # Toolkits to check for if none is explicitly specified.
        known_toolkits = ('qt4', 'wx', 'null')

        for tk in known_toolkits:
            try:
                with provisional_toolkit(tk):
                    be = import_toolkit(tk)
                break
            except ImportError as exc:
                msg = "Could not import Pyface backend '{0}'"
                logger.info(msg.format(tk))
                if logger.getEffectiveLevel() <= logging.INFO:
                    logger.exception(exc)
        else:
            # Try to import the null toolkit but don't set the ETSConfig toolkit
            try:
                be = import_toolkit('null')
                import warnings
                msg = ("Unable to import the '{0}' backend for pyface; " +
                       "using the 'null' backend instead.")
                warnings.warn(msg.format(toolkit_name), RuntimeWarning)
            except ImportError as exc:
                logger.exception(exc)
                raise ImportError("Unable to import a pyface backend for any "
                    "of the %s toolkits" % ", ".join(known_toolkits))

    # Save the imported toolkit module.
    global _toolkit_backend
    _toolkit_backend = be


# Do this once then disappear.
Initialise the current toolkit.
dataset/ETHPy150Open enthought/pyface/pyface/toolkit.py/_init_toolkit