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

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

    if ETSConfig.toolkit:
        # If the toolkit has been explicitly specified, just import it and
        # allow failure if an exception is thrown.
        import_toolkit(ETSConfig.toolkit)
        tk = ETSConfig.toolkit
    else:
        # Toolkits to check for if none is explicitly specified.
        known_toolkits = ('wx', 'qt4', 'null')

        for tk in known_toolkits:
            try:
                import_toolkit(tk)

                # In case we have just decided on a toolkit, tell everybody else.
                ETSConfig.toolkit = tk
                break
            except __HOLE__:
                pass
        else:
            # Try to import the null toolkit but don't set the ETSConfig toolkit
            try:
                tk = 'null'
                import_toolkit(tk)

                import warnings
                warnings.warn("Unable to import the %s backend for pyface;"\
                              " using the 'null' toolkit instead." % ", ".join(toolkits))
            except:
                raise ImportError("unable to import a pyface backend for any of the %s toolkits" \
                                  % ", ".join(known_toolkits))

    # Save the imported toolkit name.
    global _toolkit
    _toolkit = tk

# Do this once then disappear.
dataset/ETHPy150Open enthought/mayavi/tvtk/pyface/toolkit.py/_init_toolkit