

def _init_toolkit():
    ' Initialise the current toolkit. '

    def import_toolkit(tk):
        try:
            be = ('pyface.ui.%s.' % tk)
            __import__((be + 'init'))
        except:
            raise
        return be
    if ETSConfig.toolkit:
        be = import_toolkit(ETSConfig.toolkit)
    else:
        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:
                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)))
    global _toolkit_backend
    _toolkit_backend = be

dataset/ETHPy150Open enthought/pyface/pyface/toolkit.py _init_toolkit/original